-
Notifications
You must be signed in to change notification settings - Fork 38
/
PubDir.pm
executable file
·102 lines (79 loc) · 3.96 KB
/
PubDir.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::PubDir;
use strict;
use warnings;
use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');
sub check {
my $this = shift;
$this->{filecount} = 0;
$this->{fileErrors} = 0;
$this->{excessPerms} = 0;
my $e = $this->guessMajorDir( 'PubDir', 'pub' );
$e .= $this->NOTE(<<MISSING
If PubDir is missing, your ScriptDir is probably not located in the Foswiki
installation directory. All directory locations are guessed relative to the
ScriptDir location. (<code>$Foswiki::cfg{ScriptDir}</code>) Carefully review all of the Directory settings, especially
the WorkingDir, which will be created in the guessed location after the settings are saved.
MISSING
) if ($e =~ m/Error/);
$e .= $this->warnAboutWindowsBackSlashes( $Foswiki::cfg{PubDir} );
# Don't check directories against {RCS} permissions on Windows
my $dirchk =
( $Foswiki::cfg{OS} eq 'WINDOWS' )
? ''
: 'd';
# rwd - Readable, Writable, and directory must match {RCS}{dirPermission}
my $e2 =
$this->checkTreePerms( $Foswiki::cfg{PubDir}, 'rw' . $dirchk, qr/,v$/ );
$e .=
( $this->{filecount} >= $Foswiki::cfg{PathCheckLimit} )
? $this->NOTE(
"File checking limit $Foswiki::cfg{PathCheckLimit} reached, checking stopped - see expert options"
)
: $this->NOTE("File count: $this->{filecount} ");
my $dperm = sprintf( '%04o', $Foswiki::cfg{RCS}{dirPermission} );
my $fperm = sprintf( '%04o', $Foswiki::cfg{RCS}{filePermission} );
my $singularOrPlural = $this->{fileErrors} == 1 ? "$this->{fileErrors} directory or file has insufficient permissions." : "$this->{fileErrors} directories or files have insufficient permissions.";
if ( $this->{fileErrors} ) {
$e .= $this->ERROR(<<ERRMSG)
$singularOrPlural Insufficient permissions
could prevent Foswiki or the web server from accessing or updating the files.
Verify that the Store expert settings of {RCS}{filePermission} ($fperm) and {RCS}{dirPermission} ($dperm)
are set correctly for your environment and correct the file permissions listed below.
ERRMSG
}
if ( $this->{excessPerms}) {
$e .= $this->WARN(<<PERMS);
$this->{excessPerms} or more directories appear to have more access permission than requested in the Store configuration.
Excess permissions might allow other users on the web server to have undesired access to the files.
Verify that the Store expert settings of {RCS}{filePermission} ($fperm} and {RCS}{dirPermission}) ($dperm})
are set correctly for your environment and correct the file permissions listed below. (Files are not checked for
excessive permissions in this release).
PERMS
}
$e .= $this->NOTE('<b>First 10 detected errors of insufficient, or excessive permissions</b> <br/> ' . $e2 ) if $e2;
$this->{filecount} = 0;
$this->{fileErrors} = 0;
return $e;
}
1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
Additional copyrights apply to some or all of the code in this
file as follows:
Copyright (C) 2000-2006 TWiki Contributors. All Rights Reserved.
TWiki Contributors are listed in the AUTHORS file in the root
of this distribution. NOTE: Please extend that file, not this notice.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. For
more details read LICENSE in the root of this distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
As per the GPL, removal of this notice is prohibited.