Compare commits

...

2 Commits

3 changed files with 21 additions and 10 deletions
+7 -1
View File
@@ -1,7 +1,13 @@
1.2.2 1.2.3
- Logging fixups: Don't traceback for non-UTF-8 data in mail headers and
don't put byte string markers in logs (some remain, but are from dkimpy
and should be fixed there), related to LP: #1980821.
1.2.2 2020-08-09
- Improve README.md formating for markdown display on pypi - Improve README.md formating for markdown display on pypi
- Improve documentation in dkimpy-milter.conf (5) and README.md for signing - Improve documentation in dkimpy-milter.conf (5) and README.md for signing
for multiple domains (Thanks to Stefano Rivera) for multiple domains (Thanks to Stefano Rivera)
- Minimal fix for dnspython 2.0.0 compatibility (still works with 1.16.0)
1.2.1 2020-01-04 1.2.1 2020-01-04
- Fix expand option not to fail if files are missing since socket activation - Fix expand option not to fail if files are missing since socket activation
+13 -8
View File
@@ -107,9 +107,10 @@ class dkimMilter(Milter.Base):
# envfrom (MAIL FROM in the SMTP protocol) seems to mark the start # envfrom (MAIL FROM in the SMTP protocol) seems to mark the start
# of each message. # of each message.
@Milter.noreply @Milter.noreply
def envfrom(self, f, *str): def envfrom(self, f, *stri):
if self.conf.get('Syslog') and self.conf.get('debugLevel') >= 2: if self.conf.get('Syslog') and self.conf.get('debugLevel') >= 2:
syslog.syslog("mail from: {0} {1}".format(f, str)) f = str(bytes(f, encoding='utf-8', errors='replace'))[2:-1]
syslog.syslog("mail from: {0} {1}".format(f, stri))
self.fp = io.BytesIO() self.fp = io.BytesIO()
self.mailfrom = f self.mailfrom = f
t = parse_addr(f) t = parse_addr(f)
@@ -133,7 +134,8 @@ class dkimMilter(Milter.Base):
if lname == 'dkim-signature': if lname == 'dkim-signature':
if (self.conf.get('Syslog') and if (self.conf.get('Syslog') and
self.conf.get('debugLevel') >= 1): self.conf.get('debugLevel') >= 1):
syslog.syslog("{0}: {1}".format(name, val)) val2 = str(bytes(val, encoding='utf-8', errors='replace'))[2:-1]
syslog.syslog("{0}: {1}".format(name, val2))
self.has_dkim += 1 self.has_dkim += 1
if lname == 'from': if lname == 'from':
fname, self.author = parseaddr(val) fname, self.author = parseaddr(val)
@@ -143,7 +145,8 @@ class dkimMilter(Milter.Base):
pass # self.author was not a proper email address pass # self.author was not a proper email address
if (self.conf.get('Syslog') and if (self.conf.get('Syslog') and
self.conf.get('debugLevel') >= 1): self.conf.get('debugLevel') >= 1):
syslog.syslog("{0}: {1}".format(name, val)) val2 = str(bytes(val, encoding='utf-8', errors='replace'))[2:-1]
syslog.syslog("{0}: {1}".format(name, val2))
elif lname == 'authentication-results': elif lname == 'authentication-results':
self.arheaders.append(val) self.arheaders.append(val)
if self.fp: if self.fp:
@@ -181,7 +184,8 @@ class dkimMilter(Milter.Base):
self.chgheader('authentication-results', i, '') self.chgheader('authentication-results', i, '')
if (self.conf.get('Syslog') and if (self.conf.get('Syslog') and
self.conf.get('debugLevel') >= 1): self.conf.get('debugLevel') >= 1):
syslog.syslog('REMOVE: {0}'.format(val)) val2 = str(bytes(val, encoding='utf-8', errors='replace'))[2:-1]
syslog.syslog('REMOVE: {0}'.format(val2))
except: except:
# Don't error out on unparseable AR header fiels # Don't error out on unparseable AR header fiels
pass pass
@@ -428,7 +432,8 @@ class dkimMilter(Milter.Base):
if self.conf.get('Syslog'): if self.conf.get('Syslog'):
if d.domain: if d.domain:
syslog.syslog('DKIM: Fail ({0})' syslog.syslog('DKIM: Fail ({0})'
.format(d.domain.lower())) .format(str(d.domain.lower(), 'UTF-8',
errors='replace')))
else: else:
syslog.syslog('DKIM: Fail, unextractable domain') syslog.syslog('DKIM: Fail, unextractable domain')
if res: if res:
@@ -438,13 +443,13 @@ class dkimMilter(Milter.Base):
res = False res = False
if self.header_d: if self.header_d:
self.arresults.append( self.arresults.append(
authres.DKIMAuthenticationResult(result=result, authres.DKIMAuthenticationResult(result=result[2:-1],
header_i=self.header_i, header_i=self.header_i,
header_d=self.header_d, header_d=self.header_d,
header_a=self.header_a, header_a=self.header_a,
result_comment= result_comment=
self.dkim_comment) self.dkim_comment)
) )
self.header_a = None self.header_a = None
return return
+1 -1
View File
@@ -127,7 +127,7 @@ def DNSLookup_dnspython(name,qtype,tcpfallback=True,timeout=5):
elif qtype == 'PTR': elif qtype == 'PTR':
retVal.append(((name, qtype), rdata.target.to_text(True))) retVal.append(((name, qtype), rdata.target.to_text(True)))
elif qtype == 'TXT' or qtype == 'SPF': elif qtype == 'TXT' or qtype == 'SPF':
retVal.append(((name, qtype), rdata.strings)) retVal.append(((name, qtype), list(rdata.strings)))
except dns.resolver.NoAnswer: except dns.resolver.NoAnswer:
pass pass
except dns.resolver.NXDOMAIN: except dns.resolver.NXDOMAIN: