Adapt to MTAs that use ':' as key terminator and/or add null char to

key/value.
This commit is contained in:
Stuart D. Gathman
2022-07-15 19:00:41 -04:00
parent 7deec90a59
commit dce7c0080a
2 changed files with 12 additions and 2 deletions
+9 -1
View File
@@ -27,6 +27,10 @@ class MTAPolicy(object):
if not access_file:
access_file = conf.access_file
self.use_nulls = conf.access_file_nulls
try:
self.use_colon = conf.access_file_colon
except:
self.use_colon = True
self.sender = sender
self.domain = sender.split('@')[-1].lower()
self.acf = None
@@ -52,7 +56,11 @@ class MTAPolicy(object):
if not acf: return None
if self.use_nulls: sfx = b'\x00'
else: sfx = b''
pfx = pfx.encode() + b'!'
if self.use_colon:
sep = b':'
else:
sep = b'!'
pfx = pfx.encode() + sep
try:
return acf[pfx + self.sender.encode() + sfx].rstrip(b'\x00').decode()
except KeyError:
+3 -1
View File
@@ -11,9 +11,11 @@ sending DSNs or doing CBVs.
# Requirements
Python milter extension: https://pypi.python.org/pypi/pymilter/
Python milter extension: https://pypi.org/project/pymilter/
Python: http://www.python.org
Sendmail: http://www.sendmail.org
or
Postfix: http://www.postfix.org/MILTER_README.html
# Quick Installation