summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-08-13 02:03:46 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-08-13 02:03:46 +0100
commit33aadb27275d63c0c9691c78d147260e5f58e7bd (patch)
tree1f3a44896ab633858c4d07c9e725125975c4b55c /bin
parentaf7a8ae9e855f2dcbd74d0b71f91cbf960a731b3 (diff)
downloadpykolab-33aadb27275d63c0c9691c78d147260e5f58e7bd.tar.gz
Lower-case email addresses and attributes for comparison
PREPEND Sender: header
Diffstat (limited to 'bin')
-rwxr-xr-xbin/kolab_smtp_access_policy.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/bin/kolab_smtp_access_policy.py b/bin/kolab_smtp_access_policy.py
index bc238b5..c13bfaf 100755
--- a/bin/kolab_smtp_access_policy.py
+++ b/bin/kolab_smtp_access_policy.py
@@ -454,9 +454,9 @@ class PolicyRequest(object):
for search_attr in search_attrs:
if self.sasl_user.has_key(search_attr):
if isinstance(self.sasl_user[search_attr], list):
- if self.sender in self.sasl_user[search_attr]:
+ if self.sender.lower() in [x.lower() for x in self.sasl_user[search_attr]]:
return True
- elif self.sasl_user[search_attr] == self.sender:
+ elif self.sasl_user[search_attr].lower() == self.sender.lower():
return True
return False
@@ -1262,7 +1262,10 @@ def hold(message, policy_request=None):
def permit(message, policy_request=None):
log.info(_("Returning action PERMIT: %s") % (message))
- print "action=PERMIT\n\n"
+ if hasattr(policy_request, 'sasl_username'):
+ print "action=PREPEND Sender: %s\naction=PERMIT\n\n" % (policy_request.sasl_username)
+ else:
+ print "action=PERMIT\n\n"
sys.exit(0)
def reject(message, policy_request=None):
@@ -1299,13 +1302,13 @@ def normalize_address(email_address):
# Take the first part split by recipient delimiter and the last part
# split by '@'.
return "%s@%s" % (
- email_address.split("+")[0],
+ email_address.split("+")[0].lower(),
# TODO: Under some conditions, the recipient may not be fully
# qualified. We'll cross that bridge when we get there, though.
- email_address.split('@')[1]
+ email_address.split('@')[1].lower()
)
else:
- return email_address
+ return email_address.lower()
def read_request_input():
"""
@@ -1453,4 +1456,4 @@ if __name__ == "__main__":
elif not recipient_allowed:
reject(_("Recipient access denied"))
else:
- permit(_("No objections"))
+ permit(_("No objections"), policy_requests[instance])