Hello, I've recently converted from using procmail as an lda to using lmtp+sieve (and it's overall great). My setup is currently doing post-queue spamassassin to pickup user rules (and to be substantially similar to how it worked before). It mostly works, but I get some mail forwarded from another host that also runs spamassassin, so the mail comes with X-Spam headers already set. I can see that my sieve_before script successfully sends the message off to spamc/spamd - however the message ends up in my mailbox with only the pre-existing X-Spam headers (I had expected them to be replaced or to see duplicates). I thought I'd try to just strip them from incoming mail so I used deleteheader, I got a trace saying it matches and deletes the headers, then sends the mail off to spamc/spamd - but the message that ends up in my mailbox has the headers that were presumably deleted. My before.sieve looks like this: require ["vnd.dovecot.filter","editheader"]; # rule:[spamfilter] if size :under 10485760 { deleteheader :matches "X-Spam-Flag" "*"; deleteheader :matches "X-Spam-Status" "*"; deleteheader :matches "X-Spam-Level" "*"; deleteheader :matches "X-Spam-Checker-Version" "*"; filter "spamc" ["-s","10485760","-U","/var/run/spamd.sock"]; } Trace file says: ## Started executing script 'before' 6: size :under test 6: comparing message size 4197 6: with lower limit 10485760 6: jump if result is false 6: not jumping 11: deleteheader command 11: deleting matching occurrences of header `X-Spam-Flag' 11: header `X-Spam-Flag' not found 12: deleteheader command 12: deleting matching occurrences of header `X-Spam-Status' 12: starting `:matches' match with `i;ascii-casemap' comparator: 12: matching value `No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_.. .' 12: with key `*' => 1 12: deleting header with value `No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALI D_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham au tolearn_force=no version=3.4.2' 12: finishing match with result: matched 13: deleteheader command 13: deleting matching occurrences of header `X-Spam-Level' 13: header `X-Spam-Level' not found 14: deleteheader command 14: deleting matching occurrences of header `X-Spam-Checker-Version' 14: starting `:matches' match with `i;ascii-casemap' comparator: 14: matching value `SpamAssassin 3.4.2 (2018-09-13) on braeburn.macports.org' 14: with key `*' => 1 14: deleting header with value `SpamAssassin 3.4.2 (2018-09-13) on braeburn.macports.org' 14: finishing match with result: matched 16: filter action 16: execute program `spamc' 16: executed program successfully 16: changed message ## Finished executing script 'before' It then falls through my personal sieve filter and hits the implicit keep at the end and ends up in my inbox - with the original headers. So, two questions: 1. What am I missing? 2. Is there a way to match any X-Spam-* header? (when I tried deleteheader :matches "X-Spam*" it didn't match anything). Thanks. -- Daniel J. Luke
Hi!> It then falls through my personal sieve filter and hits the implicit > keep at the end and ends up in my inbox - with the original headers.I had a similar issue recently (with addheader, not deleteheader) and I was pointed to the RFC: https://datatracker.ietf.org/doc/html/rfc5293#section-5 ``` The deleteheader action does not affect Sieve's implicit keep. ``` My addheader case was solved by adding an explicit keep or a fileinto. I hope that will also help you, Vincent -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 833 bytes Desc: OpenPGP digital signature URL: <https://dovecot.org/pipermail/dovecot/attachments/20210611/219f0e6c/attachment.sig>
On 11/06/2021 04:25, Daniel J. Luke wrote:> Hello, > > I've recently converted from using procmail as an lda to using lmtp+sieve (and it's overall great). > > My setup is currently doing post-queue spamassassin to pickup user rules (and to be substantially similar to how it worked before). It mostly works, but I get some mail forwarded from another host that also runs spamassassin, so the mail comes with X-Spam headers already set. > > I can see that my sieve_before script successfully sends the message off to spamc/spamd - however the message ends up in my mailbox with only the pre-existing X-Spam headers (I had expected them to be replaced or to see duplicates). I thought I'd try to just strip them from incoming mail so I used deleteheader, I got a trace saying it matches and deletes the headers, then sends the mail off to spamc/spamd - but the message that ends up in my mailbox has the headers that were presumably deleted.I cannot reproduce this with master. Keep and implicit keep act the same. My filter program successfully changes the message and the deleteheader commands properly drop the indicated headers. What version is this? What is your configuration (output from `dovecot -n`) Regards, Stephan.> My before.sieve looks like this: > > require ["vnd.dovecot.filter","editheader"]; > > # rule:[spamfilter] > if size :under 10485760 > { > deleteheader :matches "X-Spam-Flag" "*"; > deleteheader :matches "X-Spam-Status" "*"; > deleteheader :matches "X-Spam-Level" "*"; > deleteheader :matches "X-Spam-Checker-Version" "*"; > > filter "spamc" ["-s","10485760","-U","/var/run/spamd.sock"]; > } > > Trace file says: > > ## Started executing script 'before' > 6: size :under test > 6: comparing message size 4197 > 6: with lower limit 10485760 > 6: jump if result is false > 6: not jumping > 11: deleteheader command > 11: deleting matching occurrences of header `X-Spam-Flag' > 11: header `X-Spam-Flag' not found > 12: deleteheader command > 12: deleting matching occurrences of header `X-Spam-Status' > 12: starting `:matches' match with `i;ascii-casemap' comparator: > 12: matching value `No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_.. > .' > 12: with key `*' => 1 > 12: deleting header with value `No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALI > D_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham au > tolearn_force=no version=3.4.2' > 12: finishing match with result: matched > 13: deleteheader command > 13: deleting matching occurrences of header `X-Spam-Level' > 13: header `X-Spam-Level' not found > 14: deleteheader command > 14: deleting matching occurrences of header `X-Spam-Checker-Version' > 14: starting `:matches' match with `i;ascii-casemap' comparator: > 14: matching value `SpamAssassin 3.4.2 (2018-09-13) on braeburn.macports.org' > 14: with key `*' => 1 > 14: deleting header with value `SpamAssassin 3.4.2 (2018-09-13) on braeburn.macports.org' > 14: finishing match with result: matched > 16: filter action > 16: execute program `spamc' > 16: executed program successfully > 16: changed message > ## Finished executing script 'before' > > It then falls through my personal sieve filter and hits the implicit keep at the end and ends up in my inbox - with the original headers. > > So, two questions: > 1. What am I missing? > 2. Is there a way to match any X-Spam-* header? (when I tried deleteheader :matches "X-Spam*" it didn't match anything). > > Thanks. >