develooper Front page | perl.qpsmtpd | Postings from February 2005

Suggested change to check_badrcptto

Thread Previous | Thread Next
From:
Tim Meadowcroft
Date:
February 20, 2005 10:34
Subject:
Suggested change to check_badrcptto
Message ID:
200502201833.41137.tim@schmerg.com

check_badrcptto replies with an error on bad recipients, but doesn't do 
anything else much as it stands (and luckily it only reads the first word of 
each line of its config file badrcptto).

I have a couple of email addresses that are ONLY used by spammers - if one of 
these is quoted as a recipient I'd like to reject the entire message for 
delivery to ANY of the recipients. This is a little extreme perhaps, so I'm 
suggesting a backward compatible change to check_badrcptto.

I'd suggest if a name is followed by an exclamation mark, this means do a 
DENYHARD, otherwise it does a plain DENY (ie "tim" - will reject this 
recipient, "tim !" will reject all emails that include "tim" amongst the 
recipients).

Patch against the CVS version:

--- plugins/check_badrcptto.orig    2005-02-20 17:39:10.000000000 +0000
+++ plugins/check_badrcptto     2005-02-20 17:47:31.664349368 +0000
@@ -11,12 +11,14 @@
   return (DECLINED) unless $recipient->host && $recipient->user;
   my $host = lc $recipient->host;
   my $from = lc($recipient->user) . '@' . $host;
-  for my $bad (@badrcptto) {
+  for (@badrcptto) {
+    my($bad,$denyhard) = /^\s*(\S+)\s*(\S*)/ or next;
+    my $denycode = $denyhard ? DENYHARD : DENY;
     $bad = lc $bad;
-    $bad =~ s/^\s*(\S+)/$1/;
-    return (DENY, "mail to $bad not accepted here")
+
+    return ($denycode, "mail to $bad not accepted here")
       if $bad eq $from;
-    return (DENY, "mail to $bad not accepted here")
+    return ($denycode, "mail to $bad not accepted here")
       if substr($bad,0,1) eq '@' && $bad eq "\@$host";
   }
   return (DECLINED);

On a related note, the DENYHARD code seems a little neglected - it's not 
documented in Constants.pm, and it only seems to be supported in "mail" and 
"rcpt" hooks (where it causes an immediate disconnect) - other handlers don't 
examine it which means it'll typically be handled as if it were DECLINED, 
which doesn't seem that smart a default.

Is DENYHARD generally to be considered a hack, deprecated, too new, or what ??

Cheers

--
Tim

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About