]> git.donarmstrong.com Git - debbugs.git/commitdiff
add in return-path and munge From for debbugs logs are odd
authorDon Armstrong <don@donarmstrong.com>
Sat, 16 Dec 2017 00:22:19 +0000 (16:22 -0800)
committerDon Armstrong <don@donarmstrong.com>
Sat, 16 Dec 2017 00:22:19 +0000 (16:22 -0800)
bin/debbugs-spam

index d8abcc6780abe12feb2eae479eb3e4b7279e4c72..be1ab24765db5aafd472b02921f2b012fe37b612 100755 (executable)
@@ -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) {