From e1764ebb10054fddfe8d9f90ae86ae6c36eb7081 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Sat, 5 Nov 2022 17:01:21 -0500 Subject: [PATCH] Remove fatal The uses of fatal have been entirely converted to simple and structured exceptions, allowing the gatekeeper to continue processing after a bad upload is encountered. --- gatekeeper.pl | 42 +++--------------------------------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/gatekeeper.pl b/gatekeeper.pl index 8e83ecb..937b615 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -371,7 +371,7 @@ if (IN_TEST_MODE) { # override the above for testing close $gpgv; } -my %info; # package being processed; a global so fatal and mail can use it +my %info; # package being processed; a global so mail can use it =head1 INTERNALS @@ -520,7 +520,7 @@ BEGIN { } # make sure our directories all exist, or it's hopeless. -# Use die instead of fatal - this error should "never" happen. +# Use ftp_abort here - this error should "never" happen. { our $Inbox_dir; our $Scratch_dir; our $Public_dir; our $Stage_dir; for my $dir ($package_config_base, $Inbox_dir, $Scratch_dir, @@ -1334,39 +1334,6 @@ sub debug { $msg); } -# Send email with TAINTED_MSG to the ftp maintainers, as well as any -# address specified for the package. Rename the bad files with a -# leading . so we don't try to process them again. Finally, write the -# same MSG to stderr and exit badly. -# -# It's ok that we quit here without processing every file, because we'll -# be invoked again from cron in a few minutes and will look further then. -# The bad . files will eventually get cleaned up via a separate script. -# -sub fatal { - my $tainted_msg = shift; - my $send_to_user = shift; - # If we fail before we have sent a copy of the directive file contents to - # the maintainer (when running in DEBUG mode), that copy is passed along, - # and we can send it from here. - my $directive_file_contents = shift; - my $exit_code = shift; - - ftp_syslog('err', "$tainted_msg"); - - # Don't let them do perl or shell quoting tricks, but show everything - # that's definitely harmless. - # - $tainted_msg =~ s=[^-.:,/@\w\s]==g; - $tainted_msg =~ m=^([-.:,/@\w\s]+)$=; - my $msg = $1; - - our $Phase; - die {Phase => $Phase, - message => $msg, - send_to_user => $send_to_user}; -} - # # - Directive reader and parsing helpers @@ -2707,10 +2674,7 @@ foreach my $packet (@packets) { # each list element is an array reference if $directive_text && DEBUG; } - # If a send_to_user key is set, then this came from a call to fatal(). - if (defined $E->{send_to_user}) { # scaffolding for now - mail($E->{message},$E->{send_to_user}); - } elsif ($E->type_p('directive_syntax')) { + if ($E->type_p('directive_syntax')) { mail(join("\n",$E->summary,'',$E->trace_msg),1); } elsif ($E->type_p('package_configuration')) { mail($E->summary,0); -- 2.25.1