From c9f0c94b929215208bbeaefc4fd8aa99a4a2e806 Mon Sep 17 00:00:00 2001 From: Stuart Gathman <stuart@gathman.org> Date: Mon, 4 Dec 2006 18:47:04 +0000 Subject: [PATCH] Reject multiple recipients to DSN. Auto-disable gossip on DB error. --- bms.py | 23 ++++++++++++++++++----- doc/links.h | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/bms.py b/bms.py index d7d0c07..eb862b7 100644 --- a/bms.py +++ b/bms.py @@ -1,6 +1,9 @@ #!/usr/bin/env python # A simple milter that has grown quite a bit. # $Log$ +# Revision 1.72 2006/11/22 16:31:22 customdesigned +# SRS domains were missing srs_reject check when SES was active. +# # Revision 1.71 2006/11/22 01:03:28 customdesigned # Replace last use of deprecated rfc822 module. # @@ -807,14 +810,19 @@ class bmsMilter(Milter.Milter): or domain in blacklist: self.blacklist = True self.log("BLACKLIST",self.canon_from) + global gossip if gossip and domain and rc == Milter.CONTINUE: if self.spf and self.spf.result == 'pass': qual = 'SPF' else: qual = self.connectip - self.umis = gossip.umis(domain+qual,self.id+time.time()) - res,hdr,val = gossip_node.query(self.umis,domain,qual,1) - self.add_header(hdr,val) + try: + self.umis = gossip.umis(domain+qual,self.id+time.time()) + res,hdr,val = gossip_node.query(self.umis,domain,qual,1) + self.add_header(hdr,val) + except: + gossip = None + raise return rc def check_spf(self): @@ -958,8 +966,8 @@ class bmsMilter(Milter.Milter): def envrcpt(self,to,*str): # mail to MAILER-DAEMON is generally spam that bounced if to.startswith('<MAILER-DAEMON@'): - self.log('DISCARD: RCPT TO:',to,str) - return Milter.DISCARD + self.log('REJECT: RCPT TO:',to,str) + return Milter.REJECT self.log("rcpt to",to,str) t = parse_addr(to) newaddr = False @@ -1425,6 +1433,11 @@ class bmsMilter(Milter.Milter): if not self.fp: return Milter.ACCEPT # no message collected - so no eom processing + if self.is_bounce and len(self.recipients) > 1: + self.log("REJECT: DSN to multiple recipients") + self.setreply('550','5.7.1', 'DSN to multiple recipients') + return Milter.REJECT + try: # check for delayed bounce if self.delayed_failure: diff --git a/doc/links.h b/doc/links.h index 6ad3f67..0696c85 100644 --- a/doc/links.h +++ b/doc/links.h @@ -16,5 +16,6 @@ <li><a href="http://www.sendmail.org/">Sendmail.Org</a> <li><a href="http://www.openspf.org/">SPF</a> <li><a href="pysrs.html">pysrs</a> +<li><a href="http://cheeseshop.python.org/pypi/pyspf">pyspf</a> <li><a href="http://bmsi.com/python/dspam.html">pydspam</a> <li><a href="http://bmsi.com/libdspam/dspam.html">libdspam</a> -- GitLab