Finish refactoring of gather_packets/scan_incoming to use absolute names
authorJacob Bachmeyer <jcb@gnu.org>
Sun, 16 Oct 2022 00:47:51 +0000 (19:47 -0500)
committerJacob Bachmeyer <jcb@gnu.org>
Sun, 16 Oct 2022 00:47:51 +0000 (19:47 -0500)
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

index 41779d10df0451633b14a0f1e4100972f7e1706f..d94dc8d4b3d443f1c5d7c62dd52d0abf6391eef7 100755 (executable)
@@ -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