From d0be1d41d4bbba0f38123b3b5dfa0ba968b47605 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Sat, 15 Oct 2022 19:47:51 -0500 Subject: [PATCH] Finish refactoring of gather_packets/scan_incoming to use absolute names This eliminates the need to change to the incoming directory and is a step towards a goal of eliminating any dependency on the current directory and presenting only absolute file names to the system. --- gatekeeper.pl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/gatekeeper.pl b/gatekeeper.pl index 41779d1..d94dc8d 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -890,7 +890,7 @@ sub scan_incoming { # $_ remains tainted, but $ent is an untainted (and safe) copy # Examine the file; this populates an internal cache in perl. - unless (stat($ent)) { + unless (stat(File::Spec->catfile($directory, $ent))) { ftp_syslog('warning', "could not stat($ent), skipping"); next ENT } @@ -1046,7 +1046,7 @@ sub gather_packets { my $racecondition = 0; my $directive = read_directive_from_file - (File::Spec->catfile($directory,$stem.'.directive.asc')); + (File::Spec->catfile($directory, $stem.'.directive.asc')); foreach my $cell (@$directive) { next unless lc($cell->[0]) eq 'filename'; $racecondition = 1; # found a 'filename' directive @@ -1888,10 +1888,6 @@ sub cleanup { # - Main execution path # -# the chdir simplifies our filename parsing, so the base names don't -# have any directory. -chdir ($incoming_dir) - or ftp_die("FATAL: chdir($incoming_dir) failed: $!"); my @incoming = gather_packets($incoming_dir, $incoming_tmp); # Temporary scaffolding to convert the new values returned by scan_incoming -- 2.25.1