[Mailman-Users] DMARC hack

Mark Sapiro mark at msapiro.net
Sun May 24 01:39:46 CEST 2015

On 05/23/2015 02:45 PM, Allan Hansen wrote:
> So against my better judgement, I included this hack in Cleanse.py;
> 22c22
> < from email.Utils import formataddr, parseaddr
>>>from email.Utils import formataddr
> 69,74d68
> <     
> <     # Added to deal with DMARC issuej
> <     name, addrs = parseaddr(msg.get('from'))
> <     addrs += '.invalid'
> <     del msg['from']
> <     msg['from'] = formataddr((name, addrs))
> \ No newline at end of filez-

It would help me understand what you did if you would post

diff -u Cleanse.py.original Cleanse.py.new

So that your patch is not reversed and I can see context, but it looks
like you replaced

    del msg['x-pmrqc']

at the end of Cleanse.py with your added code. If that is what you did,
why delete the

    del msg['x-pmrqc']


In any case, I will refrain from discussing the merits of adding
.invalid to the domain, but why do it for all domains and not just
yahoo.com and aol.com or actually look up the From: domain's DMARC
policy and only do it for domains with DMARC p=reject.

> I don’t get compile errors, but Cleanse.pyc is not being updated. I have stopped and restarted Mailman and I have also rebooted, but same non-action. I have not tried ‘compileall’ and am not eager to, either (permissions, where to invoke, etc). Any suggestions?

Does your hack do what you expect?

Cleanse.pyc will not be updated until Mailman processes at least one
post and then only if IncomingRunner can write to Cleanse.pyc. It may be
that Cleanse.pyc is in Mailman's group but not owned by the Mailman user
and is not group writable.

None of this matters. when Python imports the module, it will notice
that Cleanse.py is newer than Cleanse.pyc and will load and compile
Cleanse.py. Then it will write the byte-compiled result to Cleanse.pyc
if it can, but in any case, it will be using the code in Cleanse.py.

If there is a problem with permissions, you can compile Cleanse.py with
compileall as a user that can write the file, but it won't change the

Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan

More information about the Mailman-Users mailing list