add DNSOverride configuration for testing

This commit is contained in:
Daniel Kahn Gillmor
2019-02-19 10:35:45 -05:00
parent 71c0c3f20a
commit 1c6030024d
3 changed files with 15 additions and 1 deletions
+6 -1
View File
@@ -260,7 +260,12 @@ class dkimMilter(Milter.Base):
for y in range(self.has_dkim): # Verify _ALL_ the signatures for y in range(self.has_dkim): # Verify _ALL_ the signatures
d = dkim.DKIM(txt) d = dkim.DKIM(txt)
try: try:
res = d.verify(idx=y) dnsoverride = milterconfig.get('DNSOverride')
if isinstance(dnsoverride, str):
syslog.syslog("DNSOverride: {0}".format(dnsoverride))
res = d.verify(idx=y, dnsfunc=lambda _x: dnsoverride)
else:
res = d.verify(idx=y)
if res: if res:
if d.signature_fields.get(b'a') == 'ed25519-sha256': if d.signature_fields.get(b'a') == 'ed25519-sha256':
self.dkim_comment = ('Good {0} signature' self.dkim_comment = ('Good {0} signature'
+2
View File
@@ -48,6 +48,7 @@ defaultConfigData = {
'DiagnosticDirectory': '', 'DiagnosticDirectory': '',
'MacroList': '', 'MacroList': '',
'MacroListVerify': '', 'MacroListVerify': '',
'DNSOverride': None,
'debugLevel': 0 # Undocumented config item for developer use 'debugLevel': 0 # Undocumented config item for developer use
} }
@@ -334,6 +335,7 @@ def _readConfigFile(path, configData=None, configGlobal={}):
'DiagnosticDirectory': 'str', 'DiagnosticDirectory': 'str',
'MacroList': 'dataset', 'MacroList': 'dataset',
'MacroListVerify': 'dataset', 'MacroListVerify': 'dataset',
'DNSOverride': 'str',
'debugLevel': 'int' 'debugLevel': 'int'
} }
+7
View File
@@ -311,6 +311,13 @@ be set:
(b) KeyTable, SigningTable, no Domain, no KeyFile, no Selector; (b) KeyTable, SigningTable, no Domain, no KeyFile, no Selector;
[fooTable options NOT IMPLEMENTED] [fooTable options NOT IMPLEMENTED]
.TP
.I DNSOverride (string)
Provide a text string that a verifying milter should use instead of
consulting the DNS on each message. This is useful primarily for
testing purposes in environments where it is awkward to modify the
system DNS resolution. It should not be used in production.
.TP .TP
.I PeerList (dataset) .I PeerList (dataset)
Identifies a set of "peers" that identifies clients whose connections Identifies a set of "peers" that identifies clients whose connections