Skip to content

Commit

Permalink
Item9211: adjust permission error messages
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@8147 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Jul 12, 2010
1 parent ae13256 commit 0ce3ce3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
10 changes: 7 additions & 3 deletions core/lib/Foswiki/Configure/Checker.pm
Expand Up @@ -136,7 +136,7 @@ Enhanced checks:
* d - Directory permission matches the permissions in {RCS}{dirPermission}
* f - File permission matches the permission in {RCS}{filePermission} (FUTURE)
If > 10 enhanced errors are encountered, reporting is stopped to avoid excessive
If > 20 enhanced errors are encountered, reporting is stopped to avoid excessive
errors to the administrator. The count of enhanced errors is reported back
to the caller by the object variable: $this->{fileErrors}
Expand Down Expand Up @@ -181,12 +181,16 @@ sub checkTreePerms {
if ( $perms =~ /d/ && -d $path ) {
my $mode = ( stat($path) )[2] & 07777;
if ( $mode != $Foswiki::cfg{RCS}{dirPermission}) {
my $omode = sprintf( '%04o', $mode );
my $operm = sprintf( '%04o', $Foswiki::cfg{RCS}{dirPermission} );
if ( ($mode & $Foswiki::cfg{RCS}{dirPermission}) == $Foswiki::cfg{RCS}{dirPermission} ) {
$permErrs .=
"$path - directory permission $omode exceeds requested $operm"
. CGI::br()
unless ( $this->{excessPerms} > 10 );
$this->{excessPerms}++;
}
else {
my $omode = sprintf( '%04o', $mode );
my $operm = sprintf( '%04o', $Foswiki::cfg{RCS}{dirPermission} );
$permErrs .=
"$path - directory insufficient permission: $omode should be $operm"
. CGI::br()
Expand Down
23 changes: 14 additions & 9 deletions core/lib/Foswiki/Configure/Checkers/DataDir.pm
Expand Up @@ -35,25 +35,30 @@ sub check {

# Also check that all files excluding non-rcs files are writable
$e2 .= $this->checkTreePerms( $Foswiki::cfg{DataDir}, "r", qr/\.txt$/ );
$e .= $this->WARN($e2) if $e2;

if ( $this->{fileErrors} > 10 ) {
my $dperm = sprintf( '%04o', $Foswiki::cfg{RCS}{dirPermission} );
my $fperm = sprintf( '%04o', $Foswiki::cfg{RCS}{filePermission} );

if ( $this->{fileErrors} ) {
$e .= $this->ERROR(<<ERRMSG)
File/Directory permission mismatch reporting stopped at 10 warnings.
$this->{fileErrors} directories or files have mismatched permissions.
Verify that the Store expert settings of {RCS}{filePermission} and {RCS}{dirPermission}
are set correctly for your environment and correct file system permissions if necessary.
$this->{fileErrors} directories or files have insufficient permissions. 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} files appear to have more access permission than is recommended.
Verify that the Store expert settings of {RCS}{filePermission} and {RCS}{dirPermission}
are set correctly for your environment and correct file system permissions if necessary.
$this->{excessPerms} files 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.
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;
$this->{excessPerms} = 0;
Expand Down
28 changes: 16 additions & 12 deletions core/lib/Foswiki/Configure/Checkers/PubDir.pm
Expand Up @@ -33,24 +33,28 @@ sub check {
)
: $this->NOTE("File count - $this->{filecount} ");

$e .= $this->WARN($e2) if $e2;
my $dperm = sprintf( '%04o', $Foswiki::cfg{RCS}{dirPermission} );
my $fperm = sprintf( '%04o', $Foswiki::cfg{RCS}{filePermission} );

if ( $this->{fileErrors} ) {
$e .= $this->ERROR(<<ERRMSG)
$this->{fileErrors} directories or files have insufficient permissions. 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} files appear to have more access permission than is recommended.
Verify that the Store expert settings of {RCS}{filePermission} and {RCS}{dirPermission}
are set correctly for your environment and correct file system permissions if necessary.
$this->{excessPerms} files 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.
PERMS
}

if ( $this->{fileErrors} > 10 ) {
$e .= $this->ERROR(<<ERRMSG)
File/Directory permission mismatch reporting stopped at 10 warnings.
$this->{fileErrors} directories or files have insufficient permissions.
Verify that the Store expert settings of {RCS}{filePermission} and {RCS}{dirPermission}
are set correctly for your environment and correct file system permissions if necessary.
ERRMSG
}
$e .= $this->NOTE('<b>First 10 detected errors of insufficient, or excessive permissions</b> <br/> ' . $e2 ) if $e2;

$this->{filecount} = 0;
$this->{fileErrors} = 0;
Expand Down

0 comments on commit 0ce3ce3

Please sign in to comment.