From 5344c5e4e3bb4dc2e69d94963ed3f2abeb021090 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Tue, 25 Oct 2022 20:27:55 -0500 Subject: [PATCH] Use revised ftp_abort in verify_clearsigned_message --- gatekeeper.pl | 59 +++++++++++++++++---------------------------------- 1 file changed, 20 insertions(+), 39 deletions(-) diff --git a/gatekeeper.pl b/gatekeeper.pl index 6c03888..95e5996 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -1394,53 +1394,34 @@ sub verify_clearsigned_message { close $gpgv_output; close $gpgv_log; close $gpgv_status; close $gpgv_flag; + our $AbortPipe = $gpgv_flag_sink; # pipe to parent + our $AbortExitCode = 120; # arbitrary 7-bit exit code + # no need to use local here; this process will either exec or abort + # Adjust close-on-exec flags: my $flags; # - clear on status and log sinks - unless ($flags = fcntl $gpgv_status_sink, F_GETFD, 0) { - print $gpgv_flag_sink "ERR: fcntl F_GETFD on status: $!\n"; - exit 120; # arbitrary 7.bit exit code - } - unless (fcntl $gpgv_status_sink, F_SETFD, $flags & ~FD_CLOEXEC) { - print $gpgv_flag_sink "ERR: fcntl F_SETFD on status: $!\n"; - exit 120; # arbitrary 7.bit exit code - } - unless ($flags = fcntl $gpgv_log_sink, F_GETFD, 0) { - print $gpgv_flag_sink "ERR: fcntl F_GETFD on log: $!\n"; - exit 120; # arbitrary 7.bit exit code - } - unless (fcntl $gpgv_log_sink, F_SETFD, $flags & ~FD_CLOEXEC) { - print $gpgv_flag_sink "ERR: fcntl F_SETFD on log: $!\n"; - exit 120; # arbitrary 7.bit exit code - } + $flags = fcntl $gpgv_status_sink, F_GETFD, 0 + 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: $!"); + $flags = fcntl $gpgv_log_sink, F_GETFD, 0 + 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: $!"); # - set on flag pipe sink - unless ($flags = fcntl $gpgv_flag_sink, F_GETFD, 0) { - print $gpgv_flag_sink "ERR: fcntl F_GETFD on flag: $!\n"; - exit 120; # arbitrary 7.bit exit code - } - unless (fcntl $gpgv_flag_sink, F_SETFD, $flags | FD_CLOEXEC) { - print $gpgv_flag_sink "ERR: fcntl F_SETFD on flag: $!\n"; - exit 120; # arbitrary 7.bit exit code - } + $flags = fcntl $gpgv_flag_sink, F_GETFD, 0 + 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: $!"); # Prepare STDIN/STDOUT/STDERR - unless (open STDIN, '<&', $gpgv_stdin) { - print $gpgv_flag_sink "ERR: set stdin: $!\n"; - exit 120; # arbitrary 7-bit exit code - } - unless (open STDOUT, '>&', $gpgv_output_sink) { - print $gpgv_flag_sink "ERR: set stdout: $!\n"; - exit 120; # arbitrary 7-bit exit code - } - unless (open STDERR, '>&', $gpgv_output_sink) { - print $gpgv_flag_sink "ERR: set stderr: $!\n"; - exit 120; # arbitrary 7-bit exit code - } + 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 print $gpgv_flag_sink "ERR: $!\n"; - exit 120; # arbitrary 7-bit exit code + exec { GPGV_BIN } @gpgv_args or ftp_abort("ERR: $!"); } # The parent continues here... -- 2.25.1