From cb33013b15a895e2ceafd3ba08580eeb96920b9f Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Tue, 8 Aug 2023 19:04:45 -0500 Subject: [PATCH] Use packet accessor methods when validating directives Encapsulating the operation list header fields here is a step towards moving some of that information up to the packet objects. --- gatekeeper.pl | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/gatekeeper.pl b/gatekeeper.pl index bdd9175..0c22f74 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -2632,29 +2632,28 @@ sub Local::Packet::Directive::_validate_directive { my $ops = $packet->{oplist}; my $stem = $packet->file_name_stem; - my $op_header = $ops->[0][1]; # Configuration must exist for the package - throw unknown_package => package_name => $op_header->{package} - unless -d File::Spec->catdir(CONF_DIR_ConfigBase, $op_header->{package}); + throw unknown_package => package_name => $packet->target_package + unless -d File::Spec->catdir(CONF_DIR_ConfigBase, $packet->target_package); # While per-directory email lists are now supported, the per-package list # is still required to be present. - throw package_configuration => package_name => $op_header->{package}, - summary => 'no email list for package '.$op_header->{package} + throw package_configuration => package_name => $packet->target_package, + summary => 'no email list for package '.$packet->target_package unless -f File::Spec->catfile - (CONF_DIR_ConfigBase, $op_header->{package}, 'email'); + (CONF_DIR_ConfigBase, $packet->target_package, 'email'); # Check that we actually have at least one command in the directive unless ($#$ops > 0) { if (not $packet->has_uploaded_file) { throw directive_syntax => - trace => [], target_directory => $op_header->{directory}, + trace => [], target_directory => $packet->target_directory, summary => 'nothing to do - no commands in directive file'; } else { # Provide a different message if this looks like an upload packet. throw directive_syntax => - trace => [], target_directory => $op_header->{directory}, + trace => [], target_directory => $packet->target_directory, summary => "no filename element in $stem.directive.asc." .' Upgrade to the latest version! ' .'See http://www.gnu.org/prep/maintain/maintain.html'; @@ -2662,7 +2661,7 @@ sub Local::Packet::Directive::_validate_directive { } # Check if this directive carries a file/validate stem if needed - if (defined $op_header->{filename}) { + if ($packet->has_uploaded_file) { # Ben Pfaff wrote: # First, "gpg -b" doesn't verify that the filename of the signed # data is correct. This means that I can rename gcc-1.2.3.tar.gz @@ -2676,8 +2675,8 @@ sub Local::Packet::Directive::_validate_directive { # the name of the uploaded file must match the stem of the directive # file name; this is how it was recognized as part of the packet. throw directive_filename_mismatch => - filename => $op_header->{filename}, stem => $stem - unless $stem eq $op_header->{filename}; + filename => $packet->upload_filename, stem => $stem + unless $stem eq $packet->upload_filename; } } -- 2.25.1