From 7a3c42cfc39d334324cba7b7f225c4f1e237bdee Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Thu, 29 Jun 2023 22:12:29 -0500 Subject: [PATCH] Use directory name objects --- gatekeeper.pl | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/gatekeeper.pl b/gatekeeper.pl index 055a150..4ce9b3e 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -1349,8 +1349,9 @@ sub keyidx_email { return map _keyidx_get('Ef'.uc), grep defined, @_ } =item @files = directory_configuration_files ( $file, $directory ) -Return list of FILEs applicable to DIRECTORY. The rule used is that each -FILE applies to its own directory and is inherited by all subdirectories. +Return list of FILEs applicable to DIRECTORY, which is a directory name +object. The rule used is that each FILE applies to its own directory and +is inherited by all subdirectories. =cut @@ -1360,7 +1361,7 @@ sub directory_configuration_files { my @candidates; - for (my @directory = File::Spec::Unix->splitdir($directory); + for (my @directory = @$directory; @directory; pop @directory) { push @candidates, File::Spec->catfile @@ -2851,8 +2852,8 @@ sub check_automake_vulnerabilities { =item archive_filepair ( $directory, $filename ) Move FILENAME (and its detached signature) from DIRECTORY in the managed -public file tree to the archive file tree. The DIRECTORY parameter is an -array reference containing a split directory name. +public file tree to the archive file tree. The DIRECTORY parameter is a +directory name object. =cut @@ -2925,9 +2926,8 @@ sub move_filepair { =item execute_install ( $directory, $step, $staged_filename ) Install a file (staged under STAGED_FILENAME) into DIRECTORY within the -managed tree according to STEP. The DIRECTORY parameter is an array -reference containing a split directory name. The destination DIRECTORY -will be created if necessary. +managed tree according to STEP. The DIRECTORY parameter is a directory +name object. The destination DIRECTORY will be created if necessary. =cut @@ -2972,7 +2972,7 @@ sub execute_install { =item execute_symlink ( $directory, $step ) Establish a symlink in DIRECTORY according to STEP. The DIRECTORY -parameter is an array reference containing a split directory name. +parameter is a directory name object. =cut @@ -3005,7 +3005,7 @@ sub execute_symlink { =item execute_rmsymlink ( $directory, $step ) Remove a symlink in DIRECTORY according to STEP. The DIRECTORY parameter -is an array reference containing a split directory name. +is a directory name object. =cut @@ -3265,8 +3265,6 @@ foreach my $packet (@packets) { # each list element is an array reference (File::Spec->catfile(CONF_DIR_Scratch, $packet->target_filename)) if $packet->has_uploaded_file; - my @directory = File::Spec::Unix->splitdir($packet->target_directory); - # If the upload installs a file, check if the final file exists; if so, # require the 'replace' option to be set. foreach my $step (@$oplist) { @@ -3274,11 +3272,11 @@ foreach my $packet (@packets) { # each list element is an array reference my $install_as = $step->[1]; my $pubfinal = File::Spec::Unix->catfile - (pub => @directory, $install_as); + (pub => @{$packet->target_directory}, $install_as); my $final_upload = File::Spec->catfile - (CONF_DIR_Public, @directory, $install_as); + (CONF_DIR_Public, @{$packet->target_directory}, $install_as); my $final_signature = File::Spec->catfile - (CONF_DIR_Public, @directory, $install_as.'.sig'); + (CONF_DIR_Public, @{$packet->target_directory}, $install_as.'.sig'); if (-e $final_signature || -e $final_upload) { unless ($packet->allow_overwrite) { @@ -3303,14 +3301,15 @@ foreach my $packet (@packets) { # each list element is an array reference foreach my $step (@{$oplist}[1..$#$oplist]) { # skip the header if ($step->[0] eq 'install') { - execute_install(\@directory, $step, $packet->target_filename); + execute_install($packet->target_directory, $step, + $packet->target_filename); } elsif ($step->[0] eq 'symlink') { - execute_symlink(\@directory, $step); + execute_symlink($packet->target_directory, $step); } elsif ($step->[0] eq 'rmsymlink') { - execute_rmsymlink(\@directory, $step); + execute_rmsymlink($packet->target_directory, $step); } elsif ($step->[0] eq 'archive') { # We now also allow archiving entire directories - archive_filepair(\@directory, $step->[1]); + archive_filepair($packet->target_directory, $step->[1]); } elsif (IN_TEST_MODE && $step->[0] eq 'no-op') { # do nothing } else { -- 2.25.1