Skip to content
Snippets Groups Projects
Commit a420148b authored by Stuart Gathman's avatar Stuart Gathman
Browse files

Parse ESMTP params

parent f4465ea8
Branches
Tags
No related merge requests found
#!/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.122 2008/05/08 21:35:56 customdesigned
# Allow explicitly whitelisted email from banned_users.
#
# Revision 1.121 2008/04/10 14:59:35 customdesigned # Revision 1.121 2008/04/10 14:59:35 customdesigned
# Configure gossip TTL. # Configure gossip TTL.
# #
...@@ -496,6 +499,12 @@ def findsrs(fp): ...@@ -496,6 +499,12 @@ def findsrs(fp):
lastln = ln lastln = ln
break break
def param2dict(str):
pairs = [x.split('=',1) for x in str]
for e in pairs:
if len(e) < 2: e.append(None)
return dict([(k.upper(),v) for k,v in pairs])
class SPFPolicy(object): class SPFPolicy(object):
"Get SPF policy by result from sendmail style access file." "Get SPF policy by result from sendmail style access file."
def __init__(self,sender): def __init__(self,sender):
...@@ -721,6 +730,9 @@ class bmsMilter(Milter.Milter): ...@@ -721,6 +730,9 @@ class bmsMilter(Milter.Milter):
# of each message. # of each message.
def envfrom(self,f,*str): def envfrom(self,f,*str):
self.log("mail from",f,str) self.log("mail from",f,str)
#param = param2dict(str)
#self.envid = param.get('ENVID',None)
#self.mail_param = param
self.fp = StringIO.StringIO() self.fp = StringIO.StringIO()
self.tempname = None self.tempname = None
self.mailfrom = f self.mailfrom = f
...@@ -1077,6 +1089,15 @@ class bmsMilter(Milter.Milter): ...@@ -1077,6 +1089,15 @@ class bmsMilter(Milter.Milter):
# track header mods separately from body mods - so use only # track header mods separately from body mods - so use only
# in emergencies. # in emergencies.
def envrcpt(self,to,*str): def envrcpt(self,to,*str):
try:
param = param2dict(str)
self.notify = param.get('NOTIFY','FAILURE,DELAY').upper().split(',')
if 'NEVER' in self.notify: self.notify = ()
#self.rcpt_param = param
except:
self.log("REJECT: invalid PARAM:",to,str)
self.setreply('550','5.7.1','Invalid SRS signature')
return Milter.REJECT
# mail to MAILER-DAEMON is generally spam that bounced # mail to MAILER-DAEMON is generally spam that bounced
if to.startswith('<MAILER-DAEMON@'): if to.startswith('<MAILER-DAEMON@'):
self.log('REJECT: RCPT TO:',to,str) self.log('REJECT: RCPT TO:',to,str)
... ...
......
...@@ -61,7 +61,7 @@ porn_words = penis, breast, pussy, horse cock, porn, xenical, diet pill, d1ck, ...@@ -61,7 +61,7 @@ porn_words = penis, breast, pussy, horse cock, porn, xenical, diet pill, d1ck,
p-e-n-i-s, hydrocodone, vicodin, xanax, vicod1n, x@nax, diazepam, p-e-n-i-s, hydrocodone, vicodin, xanax, vicod1n, x@nax, diazepam,
v1@gra, xan@x, cialis, ci@lis, frëe, xãnax, valíum, vãlium, via-gra, v1@gra, xan@x, cialis, ci@lis, frëe, xãnax, valíum, vãlium, via-gra,
x@n3x, vicod3n, penís, c0d1n, phentermine, en1arge, dip1oma, v1codin, x@n3x, vicod3n, penís, c0d1n, phentermine, en1arge, dip1oma, v1codin,
valium, rolex, sexual, fuck, adv1t valium, rolex, sexual, fuck, adv1t, vgaira, medz
# reject mail with these case sensitive strings in the subject # reject mail with these case sensitive strings in the subject
spam_words = $$$, !!!, XXX, FREE, HGH spam_words = $$$, !!!, XXX, FREE, HGH
# attachments with these extensions will be replaced with a warning # attachments with these extensions will be replaced with a warning
... ...
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
# module. To compile all three on 32-bit Intel, use: # module. To compile all three on 32-bit Intel, use:
# rpmbuild -ba --target=i386,noarch pymilter.spec # rpmbuild -ba --target=i386,noarch pymilter.spec
%define version 0.8.9 %define version 0.8.10
%define release 2 %define release 1
# what version of RH are we building for? # what version of RH are we building for?
%define redhat7 0 %define redhat7 0
...@@ -278,7 +278,7 @@ rm -rf $RPM_BUILD_ROOT ...@@ -278,7 +278,7 @@ rm -rf $RPM_BUILD_ROOT
- improved parsing into email and fullname - improved parsing into email and fullname
- implement no-DSN CBV - implement no-DSN CBV
- check for porn words in MAIL FROM fullname - check for porn words in MAIL FROM fullname
- ban IP for too many bad MAIL FROMs - ban IP for too many bad MAIL FROMs or RCPT TOs
- temperror policy in access - temperror policy in access
- no CBV for whitelisted MAIL FROM except permerror, softfail - no CBV for whitelisted MAIL FROM except permerror, softfail
* Mon Sep 24 2007 Stuart Gathman <stuart@bmsi.com> 0.8.9-1 * Mon Sep 24 2007 Stuart Gathman <stuart@bmsi.com> 0.8.9-1
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment