I have installed SpamAssassin and configured it to read preferences from sql. I realised that it wasn't reading the user's preferences, and checking the logs I saw that all requests sent by the spamc
client were executed as the spamd user.
Here it is how the spamc client is executed as configured in the master.cf
file (Postfix):
spamassassin unix - n n - - pipe
user=spamd argv=/usr/bin/spamc -f -e
/usr/sbin/sendmail -oi -f ${sender} ${recipient}
I added -u ${recipient}
to spamc, and saw in the logs that it worked, now the user's preferences are correctly fetched.
However, this sort of breaks my delivery to aliases.
Consider [email protected]
being a postfix alias to [email protected]
and to [email protected]
. Adding the above -u
to spamc
leads to non-delivery of emails to the alias.
Here's a lot of postfix when it doesn't deliver the e-mail:
Feb 14 21:12:36 mail postfix/qmgr[51620]: 6EFD11003F5: from=<[email protected]>, size=2588, nrcpt=2 (queue active)
Feb 14 21:12:37 mail postfix/pipe[51637]: 6EFD11003F5: to=<[email protected]>, orig_to=<[email protected]>, relay=spamassassin, delay=1.3, delays=0.03/0/0/1.3, dsn=2.0.0, status=sent (delivered via spamassassin service (X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ha))
Feb 14 21:12:37 mail postfix/pipe[51637]: 6EFD11003F5: to=<[email protected]>, orig_to=<[email protected]>, relay=spamassassin, delay=1.3, delays=0.03/0/0/1.3, dsn=2.0.0, status=sent (delivered via spamassassin service (X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ha))
Feb 14 21:12:37 mail postfix/qmgr[51620]: 6EFD11003F5: removed
I removed the -u ${recipient}
, things work again, but I can't find much help from the following logs:
Feb 14 21:14:36 mail postfix/master[51877]: daemon started -- version 3.4.13, configuration /etc/postfix
Feb 14 21:15:26 mail postfix/qmgr[51880]: B9C531003F5: from=<[email protected]>, size=2580, nrcpt=2 (queue active)
Feb 14 21:15:27 mail postfix/pipe[51932]: B9C531003F5: to=<[email protected]>, orig_to=<[email protected]>, relay=spamassassin, delay=1.2, delays=0.04/0.01/0/1.1, dsn=2.0.0, status=sent (delivered via spamassassin service)
Feb 14 21:15:27 mail postfix/pipe[51932]: B9C531003F5: to=<[email protected]>, orig_to=<[email protected]>, relay=spamassassin, delay=1.2, delays=0.04/0.01/0/1.1, dsn=2.0.0, status=sent (delivered via spamassassin service)
Feb 14 21:15:27 mail postfix/qmgr[51880]: B9C531003F5: removed
Feb 14 21:15:27 mail postfix/qmgr[51880]: E19B7106C31: from=<[email protected]>, size=2969, nrcpt=2 (queue active)
Feb 14 21:15:28 mail postfix/qmgr[51880]: 01875106C30: from=<[email protected]>, size=3336, nrcpt=1 (queue active)
The spamassassin logs, when it doesn't work, are these:
Sun Feb 14 21:12:36 2021 [50514] info: spamd: processing message <[email protected]> for [email protected]:5000
Sun Feb 14 21:12:36 2021 [50514] info: dns: no callback for id 21026/IN/A/bluetreehotels.com.br.dbl.spamhaus.org, ignored, packet on next debug line
Sun Feb 14 21:12:36 2021 [50514] info: dns: no likely matching queries for id 21026
Sun Feb 14 21:12:37 2021 [51696] info: util: setuid: ruid=5000 euid=5000 rgid=5000 5000 5000 egid=5000 5000 5000
Sun Feb 14 21:12:37 2021 [50514] info: spamd: clean message (-1.9/3.0) for [email protected]:5000 in 1.3 seconds, 2502 bytes.
Sun Feb 14 21:12:37 2021 [50514] info: spamd: result: . -1 - BAYES_00,SPF_HELO_PASS scantime=1.3,size=2502,[email protected],uid=5000,required_score=3.0,rhost=127.0.0.1,raddr=127.0.0.1,rport=43164,mid=<[email protected]>,bayes=0.000000,autolearn=ham autolearn_force=no
Sun Feb 14 21:12:37 2021 [50512] info: prefork: child states: II
And when it works fine, are like these:
Sun Feb 14 21:15:26 2021 [50514] info: spamd: connection from 127.0.0.1 [127.0.0.1]:43402 to port 783, fd 5
Sun Feb 14 21:15:26 2021 [50514] info: spamd: processing message <[email protected]> for spamd:5000
Sun Feb 14 21:15:26 2021 [51934] info: util: setuid: ruid=5000 euid=5000 rgid=5000 5000 5000 egid=5000 5000 5000
Sun Feb 14 21:15:27 2021 [50514] info: spamd: clean message (-0.0/5.0) for spamd:5000 in 1.1 seconds, 2494 bytes.
Sun Feb 14 21:15:27 2021 [50514] info: spamd: result: . 0 - SPF_HELO_PASS scantime=1.1,size=2494,user=spamd,uid=5000,required_score=5.0,rhost=127.0.0.1,raddr=127.0.0.1,rport=43402,mid=<[email protected]>,autolearn=ham autolearn_force=no
Any clues on why this is happening? The clear difference here is that on the spamassassin log when it doesn't work, we see that spamc
was called with the user [email protected]
(and not with [email protected]
and not with [email protected]
). None of the recipients represented by the alias got the e-mail. On the second attempt, without the -u
parameter, then spamc was executed without sending a user name (failing into the default spamd
user), and the mails got delivered to the users a
and b
.
Could it be sendmail
?
Best,
Francis
I think I fixed it. Adding
spamassassin_destination_recipient_limit = 1
tomain.cf
(postfix) did the trick.