diff options
| author | Mark Sapiro | 2016-11-04 22:04:30 -0700 |
|---|---|---|
| committer | Mark Sapiro | 2016-11-04 22:04:30 -0700 |
| commit | 838f20ddf1b772e19f2ae6dc3a064747f6ab459e (patch) | |
| tree | 0e49b35e2599fa058261c127d6909a26e4c04ead /src/mailman/rules/dmarc.py | |
| parent | fdac1fbf0016d53e59d59bee026c27be77bcaccb (diff) | |
| download | mailman-838f20ddf1b772e19f2ae6dc3a064747f6ab459e.tar.gz mailman-838f20ddf1b772e19f2ae6dc3a064747f6ab459e.tar.zst mailman-838f20ddf1b772e19f2ae6dc3a064747f6ab459e.zip | |
Diffstat (limited to 'src/mailman/rules/dmarc.py')
| -rw-r--r-- | src/mailman/rules/dmarc.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/mailman/rules/dmarc.py b/src/mailman/rules/dmarc.py index 67a8d9045..b22d50ea3 100644 --- a/src/mailman/rules/dmarc.py +++ b/src/mailman/rules/dmarc.py @@ -25,8 +25,6 @@ from dns.exception import DNSException from email.utils import parseaddr from lazr.config import as_timedelta from mailman import public -from mailman.chains.discard import DiscardChain -from mailman.chains.reject import RejectChain from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.mailinglist import DMARCModerationAction @@ -246,14 +244,15 @@ class DMARCModeration: return False dn, addr = parseaddr(msg.get('from')) if _IsDMARCProhibited(mlist, addr): - # This is something of a kludge, but we can't have this rule be - # a chain in the normal way, because a hit will cause the message - # to be held. We just flag the hit for the handler, but jump - # to the reject or discard chain if appropriate. + # If dmarc_moderation_action is discard or reject, this rule fires + # and jumps to the 'moderation' chain to do the actual discard. + # Otherwise, the rule misses but sets a flag for the dmarc handler + # to do the appropriate action. msgdata['dmarc'] = True if mlist.dmarc_moderation_action == DMARCModerationAction.discard: - DiscardChain()._process(mlist, msg, msgdata) - if mlist.dmarc_moderation_action == DMARCModerationAction.reject: + msgdata['moderation_action'] = 'discard' + msgdata['moderation_reasons'] = _('DMARC moderation') + elif mlist.dmarc_moderation_action == DMARCModerationAction.reject: listowner = mlist.owner_address # noqa F841 reason = (mlist.dmarc_moderation_notice or _('You are not allowed to post to this mailing ' @@ -263,7 +262,9 @@ class DMARCModeration: 'that your messages are being rejected in error, ' 'contact the mailing list owner at ${listowner}.')) msgdata['moderation_reasons'] = [wrap(reason)] - # Add the hit for the reject notice. - msgdata.setdefault('rule_hits', []).append('dmarc-moderation') - RejectChain()._process(mlist, msg, msgdata) + msgdata['moderation_action'] = 'reject' + else: + return False + msgdata['moderation_sender'] = addr + return True return False |
