I found a minor bug in plugins/check_badmailfrom, and I didn't know
where to send it, so I'm posting it here.

When a badmailfrom issues the "RCPT TO" command, a 550 error code is
sent with the reason it was rejected.  The default reason is supposed
to be "sorry, your envelope sender is in my badmailfrom list".

An extension to plugins/check_badmailfrom to allows people to put in a
reason for specific badmailfroms to override the default reason.
(commit cab7466c08fec71c48cba5a77beee08ec3b190a4) You put the reason
on the same line as the envelope sender you wish to deny, separated by
whitespace.

The problem is that if you don't put in a reason (which is the normal
case), the default reason doesn't get used.  Instead it uses the
envelope sender as the reason.

That's because on line 41, where it, $reason can never be empty.  The
line in config/badmailfrom would have to end in whitespace, which
isn't normal, and whitespace is trimmed at the beginning and end of
the line before it got there anyway.  (It could be a false value, but
that would mean that "0" should be the reason, not the default.)

It might not be a big deal what reason you give in this case, but
someone cared enough about it to write code to allow per-line reasons,
so there must be some people out there who do care.

Here's the patch I used to correct this minor bug:


--- original/plugins/check_badmailfrom   2009-04-02 22:48:33.000000000 -0700
+++ revision/plugins/check_badmailfrom   2009-06-19 23:18:27.000000000 -0700
@@ -37,9 +37,10 @@
   my $from = lc($sender->user) . '@' . $host;

   for my $bad (@badmailfrom) {
-    my $reason = $bad; 
-    $reason =~ s/^\s*(\S+)[\t\s]+//;
-    $reason = "sorry, your envelope sender is in my badmailfrom list" unless 
$reason;
+    my $reason = "sorry, your envelope sender is in my badmailfrom list";
+    if ($bad =~ /^\s*\S+[\t\s]+(.*)/) {
+      $reason = $1;
+    }
     $bad =~ s/^\s*(\S+).*/$1/;
     next unless $bad;  
     $bad = lc $bad;

Reply via email to