diff --git a/CHANGES b/CHANGES index 29d22dd..26944b8 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,7 @@ 0.9.5 UNRELEASED - Beta 1 (updated Alpha -> Beta warning in README and trove classifiers) - - Add support for MacroList option + - Added support for MacroList option + - Added support for MacroListVerify option 0.9.4 2018-03-09 - Create PID directory if it is missing diff --git a/dkimpy_milter/__init__.py b/dkimpy_milter/__init__.py index 02221ca..2296cb9 100644 --- a/dkimpy_milter/__init__.py +++ b/dkimpy_milter/__init__.py @@ -60,6 +60,7 @@ class dkimMilter(Milter.Base): @Milter.noreply def connect(self,hostname,unused,hostaddr): self.internal_connection = False + self.external_connection = False self.hello_name = None # sometimes people put extra space in sendmail config, so we strip self.receiver = self.getsymval('j').strip() @@ -83,6 +84,15 @@ class dkimMilter(Milter.Base): if (len(macro.split('|')) == 1 and macroresult) or macroresult in \ macro.split('|')[1:]: self.internal_connection = True + if milterconfig.get('MacroListVerify'): + macrolist = milterconfig.get('MacroListVerify') + for macro in macrolist: + macroname = macro.split('|')[0] + macroname = '{' + macroname + '}' + macroresult = self.getsymval(macroname) + if (len(macro.split('|')) == 1 and macroresult) or macroresult in \ + macro.split('|')[1:]: + self.external_connection = True if self.internal_connection: connecttype = 'INTERNAL' else: @@ -163,7 +173,7 @@ class dkimMilter(Milter.Base): domain = milterconfig.get('Domain') else: domain = '' - if (self.fdomain in domain) and (not milterconfig.get('Mode') == 'v'): + if (self.fdomain in domain) and ((not milterconfig.get('Mode') == 'v') or not self.external_connection): txt = self.fp.read() self.sign_dkim(txt) result = None diff --git a/dkimpy_milter/config.py b/dkimpy_milter/config.py index 1b3a6b2..7c7fc58 100644 --- a/dkimpy_milter/config.py +++ b/dkimpy_milter/config.py @@ -48,7 +48,8 @@ defaultConfigData = { 'InternalHosts' : '127.0.0.1', 'InternalHostsObj' : False, 'DiagnosticDirectory' : '', - 'MacroList' : '' + 'MacroList' : '', + 'MacroListVerify' : '' } @@ -337,7 +338,8 @@ def _readConfigFile(path, configData = None, configGlobal = {}): 'InternalHosts' : 'dataset', 'InternalHostsObj': 'bool', 'DiagnosticDirectory' : 'str', - 'MacroList' : 'dataset' + 'MacroList' : 'dataset', + 'MacroListVerify' : 'dataset' } # check to see if it's a file diff --git a/man/dkimpy-milter.conf.5 b/man/dkimpy-milter.conf.5 index 4d9b36f..a6f8b5e 100644 --- a/man/dkimpy-milter.conf.5 +++ b/man/dkimpy-milter.conf.5 @@ -289,6 +289,16 @@ at the time the filter receives a connection from the MTA and its availability depends upon the version of milter used to compile the filter and the version of the MTA making the connection. +.TP +.I MacroListVerify (dataset) +Defines a set of MTA-provided +.I macros +that should be checked to see if the sender has been determined to be an +external source and therefore whether or not the message should be signed. +Entries in this data set follow the same form as those of the +.I MacroList +option above. [this option is not inhereted from OpenDKIM] + .TP .I Mode (string) Selects operating modes. The string is a concatenation of characters that