Subject: | Check if permissions have changed on a file before attemting to change them |
Log-Dispatcher-File-1.22
Perl 5.6.0
Solaris 10
A Log::Dispatch::File dispatcher may take a permissions parameter. There
is no check made to determine if the permissions need to be changed.
This means that if the owner of the running process differs from the
owner of the file then the process will die.
The issue with this is that if there is a need for multiple users to log
to a particular file then permissions cannot be used within the
dispatcher configuration. This slightly undermines the use of
permissions and the automatic creation of log files by the dispatcher as
without a check on the permissions it is necessary to create the logfile
manually and remove the permissions parameter from the dispatcher.
Possible solution:
*** Log/Dispatch/File.pm Sat May 12 12:52:53 2007
--- new/Log/Dispatch/File.pm Thu Jul 12 12:57:13 2007
***************
*** 93,100 ****
if ( $self->{permissions} && ! $self->{chmodded} )
{
! chmod $self->{permissions}, $self->{filename}
! or die "Cannot chmod $self->{filename} to
$self->{permissions}: $!";
$self->{chmodded} = 1;
}
--- 93,104 ----
if ( $self->{permissions} && ! $self->{chmodded} )
{
! my $filemode = (stat $self->{filename})[2] & 07777;
! if( $filemode ne $self->{permissions} )
! {
! chmod $self->{permissions}, $self->{filename}
! or die "Cannot chmod $self->{filename} to
$self->{permissions}: $!";
! }
$self->{chmodded} = 1;
}