From 421a03022a2630162e3d0ac215ee17a0f631cfb9 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Wed, 2 Nov 2022 23:00:32 -0500 Subject: [PATCH] Add structured exception for package configuration errors --- gatekeeper.pl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/gatekeeper.pl b/gatekeeper.pl index 517c254..dbc3144 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -548,6 +548,13 @@ BEGIN { } } +{ + package Local::Exception::package_configuration; + {our @ISA = qw(Local::Exception)} + + sub package_name { (shift)->{package_name} } +} + { package Local::Exception::directive_syntax; {our @ISA = qw(Local::Exception)} @@ -2535,7 +2542,12 @@ foreach my $packet (@packets) { # each list element is an array reference $Phase = 'AA'; # Check that we have a keyring for this package: my @keyrings = directory_keyrings($op_header->{directory}); - fatal("no keyring for package $op_header->{package}",0) if ($#keyrings < 0); + unless (@keyrings) { + my $package = directory_package_name($op_header->{directory}); + throw package_configuration => + summary => "no keyring for package $package", + package_name => directory_package_name($op_header->{directory}) + } $sig_info = verify_clearsigned_message($directive_text, @keyrings); @@ -2581,6 +2593,8 @@ foreach my $packet (@packets) { # each list element is an array reference mail($E->{message},$E->{send_to_user}); } elsif ($E->type_p('directive_syntax')) { mail(join("\n",$E->{summary},'',$E->trace_msg),1); + } elsif ($E->type_p('package_configuration')) { + mail($E->{summary},0); } } else { # Exceptions thrown by perl itself come out as strings -- 2.25.1