From 33b1c391c101fb56857d6ff932f45c4ab0f9e71e Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Fri, 15 Dec 2017 16:22:19 -0800 Subject: [PATCH] add in return-path and munge From for debbugs logs are odd --- bin/debbugs-spam | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bin/debbugs-spam b/bin/debbugs-spam index d8abcc67..be1ab247 100755 --- a/bin/debbugs-spam +++ b/bin/debbugs-spam @@ -340,6 +340,17 @@ sub spam_score_bug { return @records; } +sub add_return_path { + my ($message) = @_; + ## debbugs is kind of odd, and puts "Received:" first, them "From + ## ", and doesn't have a Return-Path. Fix that up so spamassassin + ## is happy. + $message =~ + s{^(Received: at \S+\ by \S+;[^\n]+\n)(From (\S+) [^\n]+\n)} + {${1}Return-Path: $3\n$2}; + return $message; +} + sub spamc_bug { my ($record,$spamc,$spamc_opts) = @_; my $first_line = ''; @@ -358,7 +369,8 @@ sub spamc_bug { if (not $childpid) { die "Unable to fork spamc"; } - print {$spamc_in} $record->{text}; + print STDERR add_return_path($record->{text}) if $DEBUG > 1; + print {$spamc_in} add_return_path($record->{text}); close($spamc_in) or die "Unable to close spamc_in: $!"; waitpid($childpid,0); if ($? >> 8) { -- 2.39.5