From b870f8a7219c6d4713337b4c0670211a95e29a74 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Tue, 15 Nov 2022 18:10:50 -0600 Subject: [PATCH] Add target directory to directive_syntax exceptions This will allow the exception handling to easily look up the email addresses that are to be notified, since a directive_syntax exception can be thrown before the normal processing collects this information. --- gatekeeper.pl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gatekeeper.pl b/gatekeeper.pl index b66d6e2..c84edc4 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -633,6 +633,8 @@ END package Local::Exception::directive_syntax; {our @ISA = qw(Local::Exception)} + sub directory { (shift)->{directory} } + sub trace { (shift)->{trace} } sub trace_msg @@ -2091,7 +2093,7 @@ sub interpret_directive { if (@errors) { throw directive_syntax => - trace => \@trace, summary => $errors[0]; + trace => \@trace, summary => $errors[0], directory => $header{directory}; } return \@ops; @@ -2216,11 +2218,13 @@ sub validate_directive { # Check that we actually have at least one command in the directive unless ($#$ops > 0) { if (1 == scalar @$packet) { - throw directive_syntax => trace => [], + throw directive_syntax => + trace => [], directory => $op_header->{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 => [], + throw directive_syntax => + trace => [], directory => $op_header->{directory}, summary => "no filename element in $stem.directive.asc." .' Upgrade to the latest version! ' .'See http://www.gnu.org/prep/maintain/maintain.html'; @@ -2712,7 +2716,7 @@ foreach my $packet (@packets) { # each list element is an array reference # This would imply that the directive file did not contain a signed # message. There is nothing further to do. - throw directive_syntax => trace => [], + throw directive_syntax => trace => [], directory => undef, summary => "directive file $packet->[0] has no signature" if $directive_text eq ''; -- 2.25.1