From 5d4817ce5879de3dc5d15d002322a053b4752463 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Sat, 27 Feb 2021 16:30:20 -0600 Subject: [PATCH] Override configuration directories in testing mode --- upload-ftp-v1.2.pl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/upload-ftp-v1.2.pl b/upload-ftp-v1.2.pl index 09dc0b2..7553478 100755 --- a/upload-ftp-v1.2.pl +++ b/upload-ftp-v1.2.pl @@ -236,6 +236,18 @@ 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. + $ENV{TEST_BASE_DIR} =~ m/^([[:graph:] ]+$)/ && -d $1 + or die "ftp-upload: test mode: TEST_BASE_DIR not valid"; + my $basedir = $1; # untainted + $package_config_base = File::Spec->catdir($basedir, 'packages'); + $incoming_dir = File::Spec->catdir($basedir, 'incoming'); + $incoming_tmp = File::Spec->catdir($basedir, 'in-stage'); + $destfinal = File::Spec->catdir($basedir, 'pub'); + $olddestfinal = File::Spec->catdir($basedir, 'archive'); + $desttmp = File::Spec->catdir($basedir, 'stage'); + } # verify mock gpgv { open my $gpgv,'-|',GPGV_BIN, '--version' -- 2.25.1