Allow explicitly whitelisted email from banned_users.

This commit is contained in:
Stuart Gathman
2008-05-08 21:35:57 +00:00
parent 1845876665
commit f4465ea816
3 changed files with 34 additions and 19 deletions
+17 -9
View File
@@ -10,6 +10,11 @@
# CBV results. # CBV results.
# #
# $Log$ # $Log$
# Revision 1.8 2007/09/03 16:18:45 customdesigned
# Delete unparseable timestamps when loading address cache. These have
# arisen because of failure to parse MAIL FROM properly. Will have to
# tighten up MAIL FROM parsing to match RFC.
#
# Revision 1.7 2007/01/25 22:47:26 customdesigned # Revision 1.7 2007/01/25 22:47:26 customdesigned
# Persist blacklisting from delayed DSNs. # Persist blacklisting from delayed DSNs.
# #
@@ -89,8 +94,10 @@ class AddrCache(object):
except IOError: except IOError:
lock.unlock() lock.unlock()
def has_key(self,sender): def has_precise_key(self,sender):
"True if sender is cached and has not expired." """True if precise sender is cached and has not expired. Don't
try looking up wildcard entries.
"""
try: try:
lsender = sender and sender.lower() lsender = sender and sender.lower()
ts,res = self.cache[lsender] ts,res = self.cache[lsender]
@@ -98,15 +105,16 @@ class AddrCache(object):
if not ts or ts > too_old: if not ts or ts > too_old:
return True return True
del self.cache[lsender] del self.cache[lsender]
except KeyError: pass
return False
def has_key(self,sender):
"True if sender is cached and has not expired."
if self.has_precise_key(sender):
return True
try: try:
user,host = sender.split('@',1) user,host = sender.split('@',1)
return self.has_key(host) return self.has_precise_key(host)
except ValueError:
pass
except KeyError:
try:
user,host = sender.split('@',1)
return self.has_key(host)
except: pass except: pass
return False return False
+4 -3
View File
@@ -1,5 +1,3 @@
Add parseaddr test case for 'foo@bar.com <baz@barf.biz>'
Check ESMTP NOTIFY before sending real DSNs. Just use CBV if DSNs are Check ESMTP NOTIFY before sending real DSNs. Just use CBV if DSNs are
not wanted. not wanted.
@@ -22,7 +20,8 @@ MTA. The mail is flagged external, so we don't list example.com in
internal_domains (or we would get "spam from self"). But, if we try to do a internal_domains (or we would get "spam from self"). But, if we try to do a
CBV, we get "fraudulent MX", because the MX is ourself! So we need to CBV, we get "fraudulent MX", because the MX is ourself! So we need to
avoid doing CBV on such domains. Currently, we try to make sure the SPF avoid doing CBV on such domains. Currently, we try to make sure the SPF
policies don't do CBV. policies don't do CBV. The real solution is for users to use SMTP AUTH,
but some of them are stubborn.
We now don't check internal domains for incoming mail if there is an We now don't check internal domains for incoming mail if there is an
SPF record. SPF record.
@@ -190,6 +189,8 @@ Need a test module to feed sample messages to a milter though a live
sendmail and SMTP. The mockup currently used is probably not very accurate, sendmail and SMTP. The mockup currently used is probably not very accurate,
and doesn't test the threading code. and doesn't test the threading code.
DONE Add parseaddr test case for 'foo@bar.com <baz@barf.biz>'
DONE Require signed MFROM for all incoming bounces when signing all outgoing DONE Require signed MFROM for all incoming bounces when signing all outgoing
mail - except from trusted relays. mail - except from trusted relays.
+7 -1
View File
@@ -1,6 +1,9 @@
#!/usr/bin/env python #!/usr/bin/env python
# A simple milter that has grown quite a bit. # A simple milter that has grown quite a bit.
# $Log$ # $Log$
# Revision 1.121 2008/04/10 14:59:35 customdesigned
# Configure gossip TTL.
#
# Revision 1.120 2008/04/02 18:59:14 customdesigned # Revision 1.120 2008/04/02 18:59:14 customdesigned
# Release 0.8.10 # Release 0.8.10
# #
@@ -1112,8 +1115,11 @@ class bmsMilter(Milter.Milter):
self.setreply('550','5.7.1','Invalid SES signature') self.setreply('550','5.7.1','Invalid SES signature')
return Milter.REJECT return Milter.REJECT
# reject for certain recipients are delayed until after DATA # reject for certain recipients are delayed until after DATA
if auto_whitelist.has_precise_key(self.canon_from):
self.log("WHITELIST: DSN from",self.canon_from)
else:
if srs_reject_spoofed \ if srs_reject_spoofed \
and not user.lower() in ('postmaster','abuse'): and user.lower() not in ('postmaster','abuse'):
return self.forged_bounce() return self.forged_bounce()
self.data_allowed = not srs_reject_spoofed self.data_allowed = not srs_reject_spoofed