From: John Graham-C. <jgr...@us...> - 2005-12-20 19:57:46
|
Update of /cvsroot/popfile/engine/POPFile In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20878/POPFile Modified Files: Configuration.pm History.pm Logger.pm Module.pm Log Message: Ensure that the piddir, msgdir and logdir are automatically created using File::Path and expose Configuration::path_join via POPFile::Module so that we correctly concatenate paths Index: History.pm =================================================================== RCS file: /cvsroot/popfile/engine/POPFile/History.pm,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** History.pm 19 Dec 2005 11:41:53 -0000 1.38 --- History.pm 20 Dec 2005 19:57:33 -0000 1.39 *************** *** 736,741 **** my $hex_slot = sprintf( '%8.8x', $slot ); my $path = $self->get_user_path_( ! $self->global_config_( 'msgdir' ) . ! substr( $hex_slot, 0, 2 ) . '/', 0 ); $self->make_directory__( $path ); --- 736,741 ---- my $hex_slot = sprintf( '%8.8x', $slot ); my $path = $self->get_user_path_( ! $self->path_join( $self->global_config_( 'msgdir' ), ! substr( $hex_slot, 0, 2 ) . '/' ), 0 ); $self->make_directory__( $path ); *************** *** 1143,1147 **** my @msgs = sort compare_mf__ glob $self->get_user_path_( ! $self->global_config_( 'msgdir' ) . 'popfile*.msg', 0 ); if ( $#msgs != -1 ) { --- 1143,1148 ---- my @msgs = sort compare_mf__ glob $self->get_user_path_( ! $self->path_join( $self->global_config_( 'msgdir' ), ! 'popfile*.msg' ), 0 ); if ( $#msgs != -1 ) { *************** *** 1181,1185 **** unlink $self->get_user_path_( ! $self->global_config_( 'msgdir' ) . 'history_cache', 0 ); } } --- 1182,1187 ---- unlink $self->get_user_path_( ! $self->path_join( $self->global_config_( 'msgdir' ), ! 'history_cache' ), 0 ); } } Index: Module.pm =================================================================== RCS file: /cvsroot/popfile/engine/POPFile/Module.pm,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** Module.pm 19 Dec 2005 11:41:53 -0000 1.51 --- Module.pm 20 Dec 2005 19:57:33 -0000 1.52 *************** *** 593,596 **** --- 593,615 ---- # ---------------------------------------------------------------------------- # + # path_join + # + # Join two paths togther + # + # $left The LHS + # $right The RHS + # $sandbox Set to 1 if this path must be sandboxed (i.e. absolute + # paths and paths containing .. are not accepted). + # + # ---------------------------------------------------------------------------- + sub path_join + { + my ( $self, $left, $right, $sandbox ) = @_; + + return $self->configuration_()->path_join( $left, $right, $sandbox ); + } + + # ---------------------------------------------------------------------------- + # # flush_slurp_data__ # Index: Logger.pm =================================================================== RCS file: /cvsroot/popfile/engine/POPFile/Logger.pm,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** Logger.pm 19 Dec 2005 11:41:53 -0000 1.44 --- Logger.pm 20 Dec 2005 19:57:33 -0000 1.45 *************** *** 33,36 **** --- 33,38 ---- use locale; + use File::Path; + # Constant used by the log rotation code my $seconds_per_day = 60 * 60 * 24; *************** *** 137,140 **** --- 139,149 ---- $self->calculate_today__(); + # Verify that the logger directory actually exists + + eval { mkpath( $self->config_( 'logdir' ) ) }; + if ( $@ ) { + $self->log_( 0, "Failed to create directory " . $self->config_( 'logdir' ) ); + } + return 1; } *************** *** 181,185 **** $self->{debug_filename__} = $self->get_user_path_( ! $self->config_( 'logdir' ) . "popfile$self->{today__}.log", 0 ); } --- 190,195 ---- $self->{debug_filename__} = $self->get_user_path_( ! $self->path_join( $self->config_( 'logdir' ), ! "popfile$self->{today__}.log" ), 0 ); } *************** *** 196,200 **** my @debug_files = glob( $self->get_user_path_( ! $self->config_( 'logdir' ) . 'popfile*.log', 0 ) ); foreach my $debug_file (@debug_files) { --- 206,211 ---- my @debug_files = glob( $self->get_user_path_( ! $self->path_join( $self->config_( 'logdir' ), ! 'popfile*.log' ), 0 ) ); foreach my $debug_file (@debug_files) { Index: Configuration.pm =================================================================== RCS file: /cvsroot/popfile/engine/POPFile/Configuration.pm,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** Configuration.pm 19 Dec 2005 11:41:53 -0000 1.57 --- Configuration.pm 20 Dec 2005 19:57:33 -0000 1.58 *************** *** 36,39 **** --- 36,40 ---- use Getopt::Long qw(:config pass_through); + use File::Path; #---------------------------------------------------------------------------- *************** *** 157,161 **** # outside the user sandbox ! $self->{pid_file__} = $self->get_user_path( $self->config_( 'piddir' ) . 'popfile.pid', 0 ); if (defined($self->live_check_())) { --- 158,173 ---- # outside the user sandbox ! eval { mkpath( $self->config_( 'piddir' ) ) }; ! if ( $@ ) { ! $self->log_( 0, "Failed to create directory " . $self->config_( 'piddir' ) ); ! } ! eval { mkpath( $self->global_config_( 'msgdir' ) ) }; ! if ( $@ ) { ! $self->log_( 0, "Failed to create directory " . $self->global_config_( 'piddir' ) ); ! } ! ! $self->{pid_file__} = $self->get_user_path( $self->path_join( ! $self->config_( 'piddir' ), ! 'popfile.pid' ), 0 ) ; if (defined($self->live_check_())) { *************** *** 603,607 **** my ( $self, $path, $sandbox ) = @_; ! return $self->path_join__( $self->{popfile_user__}, $path, $sandbox ); } --- 615,619 ---- my ( $self, $path, $sandbox ) = @_; ! return $self->path_join( $self->{popfile_user__}, $path, $sandbox ); } *************** *** 610,619 **** my ( $self, $path, $sandbox ) = @_; ! return $self->path_join__( $self->{popfile_root__}, $path, $sandbox ); } # ---------------------------------------------------------------------------- # ! # path_join__ # # Join two paths togther --- 622,631 ---- my ( $self, $path, $sandbox ) = @_; ! return $self->path_join( $self->{popfile_root__}, $path, $sandbox ); } # ---------------------------------------------------------------------------- # ! # path_join # # Join two paths togther *************** *** 625,629 **** # # ---------------------------------------------------------------------------- ! sub path_join__ { my ( $self, $left, $right, $sandbox ) = @_; --- 637,641 ---- # # ---------------------------------------------------------------------------- ! sub path_join { my ( $self, $left, $right, $sandbox ) = @_; |