From: Jacob Bachmeyer Date: Thu, 17 Nov 2022 03:35:10 +0000 (-0600) Subject: Revise calls to ftp_abort X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=bb7b8d20a87449b55faf81d1ec1479f9cd89629c;p=gatekeeper.git Revise calls to ftp_abort Since ftp_abort is used as an alternative to the die builtin for certain severe errors, the calls are regularized to omit parentheses. --- diff --git a/gatekeeper.pl b/gatekeeper.pl index b324dde..9f8f770 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -545,7 +545,7 @@ BEGIN { for my $dir ($package_config_base, $Inbox_dir, $Scratch_dir, $Public_dir, $Stage_dir, $archive_test_dir) { - ftp_abort("FATAL: configuration problem, $dir is not a directory") + ftp_abort "FATAL: configuration problem, $dir is not a directory" unless -d $dir; } @@ -566,11 +566,11 @@ BEGIN { # test moving a file from inbox to scratch { sysopen my $test, $infile, O_WRONLY|O_CREAT|O_EXCL - or ftp_abort("FATAL: create test file in inbox: $!"); + or ftp_abort "FATAL: create test file in inbox: $!"; close $test; unless (rename $infile, $scratchfile and -f $scratchfile) { unlink $infile; - ftp_abort("FATAL: could not rename file from inbox to scratchpad: $!"); + ftp_abort "FATAL: could not rename file from inbox to scratchpad: $!"; } unlink $scratchfile; # test complete } @@ -580,15 +580,15 @@ BEGIN { # test moving a file from stage to public to archive { sysopen my $test, $stagefile, O_WRONLY|O_CREAT|O_EXCL - or ftp_abort("FATAL: create test file in staging directory: $!"); + or ftp_abort "FATAL: create test file in staging directory: $!"; close $test; unless (rename $stagefile, $pubfile and -f $pubfile) { unlink $stagefile; - ftp_abort("FATAL: could not rename file from staging to public: $!"); + ftp_abort "FATAL: could not rename file from staging to public: $!"; } unless (rename $pubfile, $arcfile and -f $arcfile) { unlink $pubfile; - ftp_abort("FATAL: could not rename file from public to archive: $!"); + ftp_abort "FATAL: could not rename file from public to archive: $!"; } unlink $arcfile; # test complete } @@ -932,26 +932,26 @@ sub _spawn_gpgv { my $flags; # - clear on status and log sinks $flags = fcntl $gpgv_status_sink, F_GETFD, 0 - or ftp_abort("ERR: fcntl F_GETFD on status: $!"); + or ftp_abort "ERR: fcntl F_GETFD on status: $!"; fcntl $gpgv_status_sink, F_SETFD, $flags & ~FD_CLOEXEC - or ftp_abort("ERR: fcntl F_SETFD on status: $!"); + or ftp_abort "ERR: fcntl F_SETFD on status: $!"; $flags = fcntl $gpgv_log_sink, F_GETFD, 0 - or ftp_abort("ERR: fcntl F_GETFD on log: $!"); + or ftp_abort "ERR: fcntl F_GETFD on log: $!"; fcntl $gpgv_log_sink, F_SETFD, $flags & ~FD_CLOEXEC - or ftp_abort("ERR: fcntl F_SETFD on log: $!"); + or ftp_abort "ERR: fcntl F_SETFD on log: $!"; # - set on flag pipe sink $flags = fcntl $gpgv_flag_sink, F_GETFD, 0 - or ftp_abort("ERR: fcntl F_GETFD on flag: $!"); + or ftp_abort "ERR: fcntl F_GETFD on flag: $!"; fcntl $gpgv_flag_sink, F_SETFD, $flags | FD_CLOEXEC - or ftp_abort("ERR: fcntl F_SETFD on flag: $!"); + or ftp_abort "ERR: fcntl F_SETFD on flag: $!"; # Prepare STDIN/STDOUT/STDERR - open STDIN, '<&', $gpgv_stdin or ftp_abort("ERR: set stdin: $!"); - open STDOUT, '>&', $gpgv_output_sink or ftp_abort("ERR: set stdout: $!"); - open STDERR, '>&', $gpgv_output_sink or ftp_abort("ERR: set stderr: $!"); + open STDIN, '<&', $gpgv_stdin or ftp_abort "ERR: set stdin: $!"; + open STDOUT, '>&', $gpgv_output_sink or ftp_abort "ERR: set stdout: $!"; + open STDERR, '>&', $gpgv_output_sink or ftp_abort "ERR: set stderr: $!"; # Exec gpgv - exec { GPGV_BIN } @gpgv_args or ftp_abort("ERR: exec: $!"); + exec { GPGV_BIN } @gpgv_args or ftp_abort "ERR: exec: $!"; } # The parent continues here... @@ -976,9 +976,9 @@ sub _spawn_gpgv { foreach my $cell ([$gpgv_stdin_source, 'message'], [$gpgv_output, 'output'], [$gpgv_log, 'log'], [$gpgv_status, 'status']) { my $flags = fcntl $cell->[0], F_GETFL, 0 - or ftp_abort("gpgv: fcntl F_GETFL $cell->[1]: $!"); + or ftp_abort "gpgv: fcntl F_GETFL $cell->[1]: $!"; fcntl $cell->[0], F_SETFL, $flags | O_NONBLOCK - or ftp_abort("gpgv: fcntl F_SETFL $cell->[1]: $!"); + or ftp_abort "gpgv: fcntl F_SETFL $cell->[1]: $!"; } return $pid, $gpgv_stdin_source, $gpgv_output, $gpgv_log, $gpgv_status; @@ -1034,7 +1034,7 @@ sub _analyze_gpgv_output { /gcx) { # $1 -- pubkey algorithm $2 -- digest algorithm # $3 -- timestamp $4 -- result code - ftp_abort('gpgv returned an ISO8601 timestamp; implementation needed') + ftp_abort 'gpgv returned an ISO8601 timestamp; implementation needed' if $3 =~ m/T/; $ret->{sig_creation} = $3; } else @@ -1058,7 +1058,7 @@ sub _analyze_gpgv_output { # $11 -- primary key fingerprint $ret->{key_fingerprint} = $2; $ret->{key_longid} = substr $2,-16; - ftp_abort('gpgv returned an ISO8601 timestamp; implementation needed') + ftp_abort 'gpgv returned an ISO8601 timestamp; implementation needed' if $4 =~ m/T/ || $5 =~ m/T/; $ret->{sig_creation} = $4; # GPG reports 0 if the signature does not expire @@ -1091,7 +1091,7 @@ sub verify_clearsigned_message { ($pid, $gpgv_stdin_source, $gpgv_output, $gpgv_log, $gpgv_status) = _spawn_gpgv(\@keyrings, '-'); - local $SIG{PIPE} = sub { ftp_abort('gpgv exited unexpectedly') }; + local $SIG{PIPE} = sub { ftp_abort 'gpgv exited unexpectedly' }; my $Rchk = ''; my $Wchk = ''; vec($Wchk, (fileno $gpgv_stdin_source), 1) = 1; vec($Rchk, (fileno $_), 1) = 1 for ($gpgv_output, $gpgv_log, $gpgv_status); @@ -1386,7 +1386,7 @@ sub sendmail { } else { $smtp = Net::SMTP->new(Host => 'localhost'); } - ftp_abort("FATAL: SMTP connection failed") unless $smtp; + ftp_abort "FATAL: SMTP connection failed" unless $smtp; $smtp->mail($sender); $smtp->recipient(unique(@$recipients), { SkipBad => 1}); @@ -1773,7 +1773,7 @@ sub scan_incoming { if DEBUG; open LSOF, '-|', @lsof_args - or ftp_abort("FATAL: cannot spawn lsof: $!");; + or ftp_abort "FATAL: cannot spawn lsof: $!";; while () { ftp_syslog('debug', "DEBUG: lsof output: $_") if DEBUG; # only look at the name lines @@ -2526,7 +2526,7 @@ sub execute_commands { our $Scratch_dir; our $Public_dir; - ftp_abort("invalid internal operation list") + ftp_abort "invalid internal operation list" unless $oplist->[0][0] eq 'header'; my $header = $oplist->[0][1]; my @directory = File::Spec::Unix->splitdir($header->{directory}); @@ -2571,7 +2571,7 @@ sub execute_commands { } elsif (IN_TEST_MODE && $step->[0] eq 'no-op') { # do nothing } else { - ftp_abort("unknown internal operation: $step->[0]"); + ftp_abort "unknown internal operation: $step->[0]"; } } } @@ -2594,7 +2594,7 @@ scan_incoming will remove those files on the next run. sub cleanup_dir { my $dir = shift; opendir(DIR, $dir) - or ftp_abort("Can’t opendir $dir in cleanup_dir: $!"); + or ftp_abort "Can’t opendir $dir in cleanup_dir: $!"; my @files = grep { !/^\./ && -f File::Spec->catfile($dir, $_) } readdir(DIR); closedir DIR;