At a loss with antispan and imap_sieve
Hi,
It seems I can’t google my way out of this one. I’m trying to set up spam/ham learning but getting nowhere.
I tried Johannes Berg Antispam plugin, and syslog shows:
Sep 20 22:22:06 proefmail imap: antispam: running mailtrain backend program /usr/lib/dovecot/retrain.sh Sep 20 22:22:06 proefmail imap: antispam: running mailtrain backend program /usr/lib/dovecot/retrain.sh Sep 20 22:22:06 proefmail imap: antispam: running mailtrain backend program parameter 1 /mail/klaas Sep 20 22:22:06 proefmail imap: antispam: running mailtrain backend program parameter 2 ham
The file retrain.sh is simply:
#!/bin/sh echo hi >> debug.log
...with debug.log being an empty world-writeable file in /usr/lib/dovecot.
Absolutely nothing happens. The file debug.log is not even touched. But when I remove retrain.sh there’s an error logged so up until then, *something* happens.
After this I tried imap_sieve, following the wiki on dovecot.org, but again nothing happens. My imap.log says: Info: sieve: pipe action: piped message to program `retrain.sh’
But again debug.log is untouched.
I’m fresh out of ideas here. Any help would be most welcome.
I’m on Debian in virtual machine, Postfix delivering mail to Dovecot LMTP delivering to virtual maildirs, bogofilter for scanning incoming mail. Sieve does work for moving incoming spam to the spam mailbox.
Cheers and thanks,
Ferenc
On 21/09/2020 00:37 Ferenc dovecot@bezemkast.nl wrote:
Hi,
It seems I can’t google my way out of this one. I’m trying to set up spam/ham learning but getting nowhere.
I tried Johannes Berg Antispam plugin, and syslog shows:
Sep 20 22:22:06 proefmail imap: antispam: running mailtrain backend program /usr/lib/dovecot/retrain.sh Sep 20 22:22:06 proefmail imap: antispam: running mailtrain backend program /usr/lib/dovecot/retrain.sh Sep 20 22:22:06 proefmail imap: antispam: running mailtrain backend program parameter 1 /mail/klaas Sep 20 22:22:06 proefmail imap: antispam: running mailtrain backend program parameter 2 ham
The file retrain.sh is simply:
#!/bin/sh echo hi >> debug.log
...with debug.log being an empty world-writeable file in /usr/lib/dovecot.
Absolutely nothing happens. The file debug.log is not even touched. But when I remove retrain.sh there’s an error logged so up until then, *something* happens.
After this I tried imap_sieve, following the wiki on dovecot.org, but again nothing happens. My imap.log says: Info: sieve: pipe action: piped message to program `retrain.sh’
But again debug.log is untouched.
I’m fresh out of ideas here. Any help would be most welcome.
I’m on Debian in virtual machine, Postfix delivering mail to Dovecot LMTP delivering to virtual maildirs, bogofilter for scanning incoming mail. Sieve does work for moving incoming spam to the spam mailbox.
Cheers and thanks,
Ferenc
Hi!
Those scripts are not ran as root, so you can't actually write to /usr/lib/dovecot, you should probably use some writable location.
Also,
https://doc.dovecot.org/configuration_manual/howto/antispam_with_sieve/
Aki
"Aki Tuomi" aki.tuomi@open-xchange.com schreef op 21 september 2020 06:23:
On 21/09/2020 00:37 Ferenc dovecot@bezemkast.nl wrote:
Hi,
It seems I can’t google my way out of this one. I’m trying to set up spam/ham learning but getting nowhere.
I tried Johannes Berg Antispam plugin, and syslog shows:
Sep 20 22:22:06 proefmail imap: antispam: running mailtrain backend program /usr/lib/dovecot/retrain.sh Sep 20 22:22:06 proefmail imap: antispam: running mailtrain backend program /usr/lib/dovecot/retrain.sh Sep 20 22:22:06 proefmail imap: antispam: running mailtrain backend program parameter 1 /mail/klaas Sep 20 22:22:06 proefmail imap: antispam: running mailtrain backend program parameter 2 ham
The file retrain.sh is simply:
#!/bin/sh echo hi >> debug.log
...with debug.log being an empty world-writeable file in /usr/lib/dovecot.
Absolutely nothing happens. The file debug.log is not even touched. But when I remove retrain.sh there’s an error logged so up until then, *something* happens.
After this I tried imap_sieve, following the wiki on dovecot.org, but again nothing happens. My imap.log says: Info: sieve: pipe action: piped message to program `retrain.sh’
But again debug.log is untouched.
I’m fresh out of ideas here. Any help would be most welcome.
I’m on Debian in virtual machine, Postfix delivering mail to Dovecot LMTP delivering to virtual maildirs, bogofilter for scanning incoming mail. Sieve does work for moving incoming spam to the spam mailbox.
Cheers and thanks,
Ferenc
Hi!
Those scripts are not ran as root, so you can't actually write to /usr/lib/dovecot, you should probably use some writable location.
Hi Aki,
Thanks for your quick reply! I tried /tmp/debug.log, world-writeable, but no dice.
https://doc.dovecot.org/configuration_manual/howto/antispam_with_sieve
I followed the setup here. I think it works up until the external script is called (pipe :copy "sa-learn-ham.sh"). That's why I tried echo hi >> /tmp/file. I guessed the scripts run as vmail, my virtual mail user, so I tried sudo -u vmail retrain.sh. This works. I can see the sieve script run in the log but my guess is the external script never runs. I'd like to try strace to see where things go when calling the external script but I don't know where to even start putting strace -o.
Ferenc
On Mon, 21 Sep 2020, Ferenc wrote:
Thanks for your quick reply! I tried /tmp/debug.log, world-writeable, but no dice.
https://doc.dovecot.org/configuration_manual/howto/antispam_with_sieve
I followed the setup here. I think it works up until the external script is called (pipe :copy "sa-learn-ham.sh"). That's why I tried echo hi >> /tmp/file. I guessed the scripts run as vmail, my virtual mail user, so I tried sudo -u vmail retrain.sh. This works. I can see the sieve script run in the log but my guess is the external script never runs. I'd like to try strace to see where things go when calling the external script but I don't know where to even start putting strace -o.
You may want to check your sieve_pipe_bin_dir setting in dovecot.conf. AFAIK the program/script you call via "pipe :copy ..." must be located in the directory defined by sieve_pipe_bin_dir.
At least I remember having issues calling rspamc in my report-ham and report-spam scripts, which was (apparently) solved after I set: sieve_pipe_bin_dir = /usr/bin
You can also use "debug_log" to output stuff from your sieve scripts into the syslog (don't forget to require "vnd.dovecot.debug" though..)
Good luck.
On 21/09/2020 11:11 Bernardo Reino reinob@bbmk.org wrote:
On Mon, 21 Sep 2020, Ferenc wrote:
Thanks for your quick reply! I tried /tmp/debug.log, world-writeable, but no dice.
https://doc.dovecot.org/configuration_manual/howto/antispam_with_sieve
I followed the setup here. I think it works up until the external script is called (pipe :copy "sa-learn-ham.sh"). That's why I tried echo hi >> /tmp/file. I guessed the scripts run as vmail, my virtual mail user, so I tried sudo -u vmail retrain.sh. This works. I can see the sieve script run in the log but my guess is the external script never runs. I'd like to try strace to see where things go when calling the external script but I don't know where to even start putting strace -o.
You may want to check your sieve_pipe_bin_dir setting in dovecot.conf. AFAIK the program/script you call via "pipe :copy ..." must be located in the directory defined by sieve_pipe_bin_dir.
At least I remember having issues calling rspamc in my report-ham and report-spam scripts, which was (apparently) solved after I set: sieve_pipe_bin_dir = /usr/bin
You can also use "debug_log" to output stuff from your sieve scripts into the syslog (don't forget to require "vnd.dovecot.debug" though..)
Good luck.
It is not necessarely a good idea to use /usr/bin here... =)
Ferenc, are you using systemd? If so, then you will discover under /tmp some private temporary directories, one of them is for dovecot, and your debug log is probably under there.
If you want to strace, try
strace -ff doveadm exec imap -u username
Aki
On Mon, 21 Sep 2020, Aki Tuomi wrote:
On 21/09/2020 11:11 Bernardo Reino reinob@bbmk.org wrote:
[...]
You may want to check your sieve_pipe_bin_dir setting in dovecot.conf. AFAIK the program/script you call via "pipe :copy ..." must be located in the directory defined by sieve_pipe_bin_dir.
At least I remember having issues calling rspamc in my report-ham and report-spam scripts, which was (apparently) solved after I set: sieve_pipe_bin_dir = /usr/bin
You can also use "debug_log" to output stuff from your sieve scripts into the syslog (don't forget to require "vnd.dovecot.debug" though..)
It is not necessarely a good idea to use /usr/bin here... =)
AFAIK the "pipe" command does not allow to specify /a/full/path (according to https://wiki.dovecot.org/Pigeonhole/Sieve/Plugins/Pipe it refuses "/" in program names), but I needed to call /usr/bin/rspamc, so that's why I did it that way.
I suppose a "cleaner" way would be to use another sive_pipe_bin_dir and place a script there which calls the actual command.
I'll keep that in mind and test it someday. I never liked the possibility of a random sieve script calling something I cannot control (even if non-root, and even if the server is exclusively for family e-mail, blah blah.. :)
Thanks for the reminder! Bernardo
"Aki Tuomi" aki.tuomi@open-xchange.com schreef op 21 september 2020 10:21:
Ferenc, are you using systemd? If so, then you will discover under /tmp some private temporary directories, one of them is for dovecot, and your debug log is probably under there.
That was it. I didn't know that. With this it was quickly solved. It was a simple typo of course. Retraining is working now, I went with the antispam plugin.
Many thanks to Aki and thanks too to the other people offering help.
Ferenc
participants (3)
-
Aki Tuomi
-
Bernardo Reino
-
Ferenc