From 902c858f19a42d39a88547767fe0d19af4e84770 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Mon, 26 Apr 2004 13:23:28 +0000 Subject: Filter out mixmaster outputs to stderr that are no problem --- Echolot/Pinger/Mix.pm | 18 ++++++++++++------ Echolot/Tools.pm | 8 ++++---- NEWS | 1 + 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Echolot/Pinger/Mix.pm b/Echolot/Pinger/Mix.pm index 1b774a2..1bb3a0d 100644 --- a/Echolot/Pinger/Mix.pm +++ b/Echolot/Pinger/Mix.pm @@ -66,7 +66,8 @@ sub ping($$$$$) { Echolot::Log::warn("Cannot close $mixcfg: $!."), return 0; - my $pid = open(KID, "|-"); + my($wtr, $rdr, $err); + my $pid = open3($wtr, $rdr, $err, "|-"); defined $pid or Echolot::Log::warn("Cannot fork for calling mixmaster: $!."), return 0; @@ -76,13 +77,18 @@ sub ping($$$$$) { Echolot::Log::warn("Cannot exec mixpinger: $!."); exit(1); }; - print KID "From: Echolot Pinger <$address>\n" - if $with_from; - print KID "To: $to\n\n$body\n"; - close (KID); + my $msg; + $msg .= "From: Echolot Pinger <$address>\n" if $with_from; + $msg .= "To: $to\n\n$body\n"; + my ($stdout, $stderr, undef) = Echolot::Tools::readwrite_gpg($msg, $wtr, $rdr, $err, undef); waitpid $pid, 0; - + + $stderr =~ s/^Chain: .*//mg; + $stderr =~ s/^Warning: The message has a From: line.*//mg; + Echolot::Log::info("Mixmaster said on stdout: $stdout"); + Echolot::Log::warn("Mixmaster said on stderr: $stderr"); + return 1; }; diff --git a/Echolot/Tools.pm b/Echolot/Tools.pm index 46b7f3e..0264cfd 100644 --- a/Echolot/Tools.pm +++ b/Echolot/Tools.pm @@ -288,14 +288,14 @@ sub readwrite_gpg($$$$$) { $inputfd->blocking(0); $stdoutfd->blocking(0); - $statusfd->blocking(0); + $statusfd->blocking(0) if defined $statusfd; $stderrfd->blocking(0); $sout->add($stdoutfd); $sout->add($stderrfd); - $sout->add($statusfd); + $sout->add($statusfd) if defined $statusfd; $sin->add($inputfd); - Echolot::Log::debug("input is $inputfd; output is $stdoutfd; err is $stderrfd; status is $statusfd."); + Echolot::Log::debug("input is $inputfd; output is $stdoutfd; err is $stderrfd; status is ".(defined $statusfd ? $statusfd : 'undef')."."); my ($stdout, $stderr, $status) = ("", "", ""); @@ -330,7 +330,7 @@ sub readwrite_gpg($$$$$) { $stdout .= <$rfd>; next; } - if ($rfd == $statusfd) { + if (defined $statusfd && $rfd == $statusfd) { $status .= <$rfd>; next; } diff --git a/NEWS b/NEWS index 0e9d45b..128c281 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ Changes in version - 2004 * Make sure we do not create empty key hashes in metadata. * gpg interaction cleanup, move a lot of duplicated code to Echolot::Tools. + * Filter out mixmaster outputs to stderr that are no problem. Changes in version 2.1.3 - 2004-04-20 * Improvements to pingd.conf(5) by Colin. -- cgit v1.2.3