From 6936b599fe4fca9a9b028c0aaaf1b0669365eb47 Mon Sep 17 00:00:00 2001 From: Stuart Gathman <stuart@gathman.org> Date: Fri, 23 Mar 2007 22:39:10 +0000 Subject: [PATCH] Get SMTP-Auth policy from access_file. --- bms.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/bms.py b/bms.py index 03fe6b6..ae8c267 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.98 2007/03/21 04:02:13 customdesigned +# Properly log From: and Sender: +# # Revision 1.97 2007/03/18 02:32:21 customdesigned # Gossip configuration options: client or standalone with optional peers. # @@ -682,7 +685,21 @@ class bmsMilter(Milter.Milter): self.setreply('550','5.7.1','I hate talking to myself.') return Milter.REJECT else: - if internal_domains: + if self.user: + p = SPFPolicy('%s@%s'%(self.user,domain)) + policy = p.getPolicy('SMTP-Auth:') + else: + policy = None + if policy: + if policy != 'OK': + self.log("REJECT: unauthorized user",self.user, + "at",self.connectip,"sending MAIL FROM",self.canon_from) + self.setreply('550','5.7.1', + 'SMTP user %s is not authorized to use MAIL FROM %s.' % + (self.user,self.canon_from) + ) + return Milter.REJECT + elif internal_domains: for pat in internal_domains: if fnmatchcase(domain,pat): break else: -- GitLab