~kosova/+junk/tuxfamily-twiki

« back to all changes in this revision

Viewing changes to foswiki/lib/Foswiki/Configure/Checkers/SafeEnvPath.pm

  • Committer: James Michael DuPont
  • Date: 2009-07-18 19:58:49 UTC
  • Revision ID: jamesmikedupont@gmail.com-20090718195849-vgbmaht2ys791uo2
added foswiki

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# See bottom of file for license and copyright information
 
2
package Foswiki::Configure::Checkers::SafeEnvPath;
 
3
use base 'Foswiki::Configure::Checker';
 
4
 
 
5
use strict;
 
6
 
 
7
use Foswiki::Configure::Checker;
 
8
 
 
9
# Unix or Linux, Windows ActiveState Perl, using PERL5SHELL set to cygwin shell
 
10
#   path separator is :
 
11
#   ensure diff and shell (Bourne or bash type) are found on
 
12
#   path.
 
13
# Windows ActiveState Perl, using DOS shell
 
14
#   path separator is ;
 
15
#   The Windows system directory (e.g. c:\winnt\system32) is required.
 
16
#   Use '\' not '/' in pathnames.
 
17
# Windows Cygwin Perl
 
18
#   path separator is :
 
19
#   The Windows system directory (e.g. /cygdrive/c/winnt/system32) is required.
 
20
#   Use '/' not '\' in pathnames.
 
21
#
 
22
sub check {
 
23
    my $this = shift;
 
24
 
 
25
    unless ( $Foswiki::cfg{SafeEnvPath} ) {
 
26
        return $this->WARN("You should set a value for this path.");
 
27
    }
 
28
 
 
29
    my $check = '';
 
30
 
 
31
    # First, get the proposed path
 
32
    my @dirs;
 
33
    if ( $Foswiki::cfg{DetailedOS} eq 'MSWin32' ) {
 
34
 
 
35
        # Active State perl, probably. Need DOS paths.
 
36
        @dirs = split( ';', $Foswiki::cfg{SafeEnvPath} );
 
37
    }
 
38
    else {
 
39
        @dirs = split( ':', $Foswiki::cfg{SafeEnvPath} );
 
40
    }
 
41
 
 
42
    # Check they exist
 
43
    my $found = 0;
 
44
    foreach my $dir (@dirs) {
 
45
        if ( -d $dir ) {
 
46
            $found++;
 
47
        }
 
48
        else {
 
49
            $check .= $this->WARN("$dir could not be found");
 
50
        }
 
51
    }
 
52
    if ( $Foswiki::cfg{DetailedOS} eq 'MSWin32' && !$found ) {
 
53
        $check .= $this->ERROR(
 
54
"None of the directories on the path could be found. This path will almost certainly not work on Windows. Normally the minimum acceptable {SafeEnvPath} is C:\\WINDOWS\\System32 (or the equivalent on your system)."
 
55
        );
 
56
    }
 
57
 
 
58
    return $check;
 
59
}
 
60
 
 
61
1;
 
62
__DATA__
 
63
# Foswiki - The Free and Open Source Wiki, http://foswiki.org/
 
64
#
 
65
# Copyright (C) 2008 Foswiki Contributors. All Rights Reserved.
 
66
# Foswiki Contributors are listed in the AUTHORS file in the root
 
67
# of this distribution. NOTE: Please extend that file, not this notice.
 
68
#
 
69
# Additional copyrights apply to some or all of the code in this
 
70
# file as follows:
 
71
#
 
72
# Copyright (C) 2000-2006 TWiki Contributors. All Rights Reserved.
 
73
# TWiki Contributors are listed in the AUTHORS file in the root
 
74
# of this distribution. NOTE: Please extend that file, not this notice.
 
75
#
 
76
# This program is free software; you can redistribute it and/or
 
77
# modify it under the terms of the GNU General Public License
 
78
# as published by the Free Software Foundation; either version 2
 
79
# of the License, or (at your option) any later version. For
 
80
# more details read LICENSE in the root of this distribution.
 
81
#
 
82
# This program is distributed in the hope that it will be useful,
 
83
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
84
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
85
#
 
86
# As per the GPL, removal of this notice is prohibited.