From: Jacob Bachmeyer Date: Wed, 17 Mar 2021 03:04:00 +0000 (-0500) Subject: Use constant for name of lsof executable to enable testing with mock X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ae0d6a5d9be6fd06d11d09d6eb57f091a2eb0dfb;p=gatekeeper.git Use constant for name of lsof executable to enable testing with mock --- diff --git a/upload-ftp-v1.2.pl b/upload-ftp-v1.2.pl index d6172e2..6c95c0d 100755 --- a/upload-ftp-v1.2.pl +++ b/upload-ftp-v1.2.pl @@ -173,10 +173,15 @@ BEGIN { # We trust our test environment, but taint mode forces this issue. $FindBin::Bin =~ m[^(/[[:graph:] ]+)$] or die "strange base path for test environment"; + my $gpgv_mock = File::Spec->catfile($1, qw(testsuite lib exec mockgpgv)); constant->import(GPGV_BIN => $gpgv_mock); + + my $sys_mock = File::Spec->catfile($1, qw(testsuite lib exec mocktool)); + constant->import(LSOF_BIN => $sys_mock, 'lsof'); } else { constant->import(GPGV_BIN => '/usr/bin/gpgv'); + constant->import(LSOF_BIN => '/usr/bin/lsof'); } } @@ -234,7 +239,6 @@ my $email_always = 'ftp-upload-script@gnu.org'; # e.g., ftp-upload@gnu.org my $facility = "LOCAL5"; if (IN_TEST_MODE) { # override the above for testing - # override PATH # override file paths to our testcase environment { # Again, the test environment is trusted, but we still run in taint mode. @@ -528,7 +532,7 @@ sub scan_incoming { # If neither of those 2 conditions are met, the lsof call will not see # the open files because they are owned by another user. # On modern (Debian) systems, condition a) is not met. - my @lsof_args = ("/usr/bin/lsof", "-Fn", + my @lsof_args = (LSOF_BIN, "-Fn", map { "$incoming_dir/$_" } keys %possible); ftp_syslog('debug', "($log_style) DEBUG: " . "lsof command line: " . join(' ',@lsof_args)) if $DEBUG; my $pid = open (LSOF, "-|");