Ben Johnson
2013-Jun-19 18:52 UTC
[Dovecot] Calling dovecot-lda from within Antispam pipe script (bash) seems to have no effect
Hello, I'm attempting to configure the Dovecot Antispam plug-in on Ubuntu 12.04 LTS with Dovecot 2.0.19. Everything seems to be in order with one considerable exception: when my pipe script (a simple Bash shell script) calls the dovecot-lda executable, absolutely nothing seems to result. If I copy/paste the exact same command into the terminal, the mail is delivered to the target mailbox, as expected. Here's my pipe script: http://pastebin.com/DBXAZqsN When I move a message from INBOX -> Junk, or from Junk -> INBOX, the pipe script is called, and here's the output: --------------------------------------------------------------- 31465-start (--debug --username=amavis --ham) Checking if the command-line input argument string (--debug --username=amavis --ham) contains the string "ham" or "spam" Mode is "HAM" Calling (as user vmail) '/usr/lib/dovecot/deliver -d "sa-training at example.com" -m "Training.HAM" -p "/tmp/sendmail-msg-31465.txt"' 31465-end --------------------------------------------------------------- But, for some reason, the call to "/usr/lib/dovecot/deliver" doesn't seem to do anything. If I copy the above output and paste it into the terminal: /usr/lib/dovecot/deliver -d "sa-training at example.com" -m "Training.HAM" -p "/tmp/sendmail-msg-31465.txt" Dovecot does indeed deliver the message. This works whether I execute the above command as "root" or "vmail". Why does this command have no effect when called from within the pipe script? Here is my "doveconf -n" output: # 2.0.19: /etc/dovecot/dovecot.conf # OS: Linux 2.6.32-042stab076.8 x86_64 Ubuntu 12.04.2 LTS auth_mechanisms = plain login disable_plaintext_auth = no listen = *,[::] log_timestamp = "%Y-%m-%d %H:%M:%S " mail_privileged_group = vmail passdb { args = /etc/dovecot/dovecot-sql.conf driver = sql } plugin { antispam_backend = pipe antispam_debug_target = syslog antispam_pipe_program = /usr/bin/sa-learn-pipe.sh antispam_pipe_program_args = --debug;--username=amavis antispam_pipe_program_notspam_arg = --ham antispam_pipe_program_spam_arg = --spam antispam_pipe_tmpdir = /tmp antispam_spam_pattern_ignorecase = SPAM;JUNK antispam_trash_pattern_ignorecase = trash;Deleted * antispam_verbose_debug = 1 quota = dict:user::file:/var/vmail/%d/%n/.quotausage quota_rule2 = Trash:storage=+100M quota_rule3 = Junk:ignore quota_warning = storage=95%% quota-warning 95 %u %d quota_warning2 = storage=80%% quota-warning 80 %u %d quota_warning3 = -storage=100%% quota-below below %u %d sieve = /var/vmail/%d/%n/.sieve } protocols = imap pop3 service auth { unix_listener /var/spool/postfix/private/auth { group = postfix mode = 0660 user = postfix } unix_listener auth-userdb { group = vmail mode = 0600 user = vmail } user = root } service quota-below { executable = script /usr/local/bin/quota-below.sh user = vmail } service quota-warning { executable = script /usr/local/bin/quota-warning.sh user = vmail } ssl_cert = </etc/postfix/smtpd.cert ssl_key = </etc/postfix/smtpd.key userdb { args = /etc/dovecot/dovecot-sql.conf driver = sql } protocol imap { mail_plugins = quota imap_quota antispam } protocol pop3 { mail_plugins = quota pop3_uidl_format = %08Xu%08Xv } protocol lda { info_log_path = /var/log/dovecot-lda.log log_path = /var/log/dovecot-lda-errors.log mail_plugins = sieve quota } Thank you, -Ben
Bob Miller
2013-Jun-20 04:14 UTC
[Dovecot] Calling dovecot-lda from within Antispam pipe script (bash) seems to have no effect
Hi Ben, I checked over your script, and I don't see the problem either. You already checked everything that comes to my mind. Maybe using something like set -e to try and get some output from the script? -- Computerisms Bob Miller 867-334-7117 / 867-633-3760 http://computerisms.ca On Wed, 2013-06-19 at 14:52 -0400, Ben Johnson wrote:> Hello, > > I'm attempting to configure the Dovecot Antispam plug-in on Ubuntu 12.04 > LTS with Dovecot 2.0.19. > > Everything seems to be in order with one considerable exception: when my > pipe script (a simple Bash shell script) calls the dovecot-lda > executable, absolutely nothing seems to result. > > If I copy/paste the exact same command into the terminal, the mail is > delivered to the target mailbox, as expected. > > Here's my pipe script: http://pastebin.com/DBXAZqsN > > When I move a message from INBOX -> Junk, or from Junk -> INBOX, the > pipe script is called, and here's the output: > > --------------------------------------------------------------- > 31465-start (--debug --username=amavis --ham) > Checking if the command-line input argument string (--debug > --username=amavis --ham) contains the string "ham" or "spam" > Mode is "HAM" > Calling (as user vmail) '/usr/lib/dovecot/deliver -d > "sa-training at example.com" -m "Training.HAM" -p > "/tmp/sendmail-msg-31465.txt"' > 31465-end > --------------------------------------------------------------- > > But, for some reason, the call to "/usr/lib/dovecot/deliver" doesn't > seem to do anything. > > If I copy the above output and paste it into the terminal: > > /usr/lib/dovecot/deliver -d "sa-training at example.com" -m "Training.HAM" > -p "/tmp/sendmail-msg-31465.txt" > > Dovecot does indeed deliver the message. This works whether I execute > the above command as "root" or "vmail". > > Why does this command have no effect when called from within the pipe > script? > > Here is my "doveconf -n" output: > > # 2.0.19: /etc/dovecot/dovecot.conf > # OS: Linux 2.6.32-042stab076.8 x86_64 Ubuntu 12.04.2 LTS > auth_mechanisms = plain login > disable_plaintext_auth = no > listen = *,[::] > log_timestamp = "%Y-%m-%d %H:%M:%S " > mail_privileged_group = vmail > passdb { > args = /etc/dovecot/dovecot-sql.conf > driver = sql > } > plugin { > antispam_backend = pipe > antispam_debug_target = syslog > antispam_pipe_program = /usr/bin/sa-learn-pipe.sh > antispam_pipe_program_args = --debug;--username=amavis > antispam_pipe_program_notspam_arg = --ham > antispam_pipe_program_spam_arg = --spam > antispam_pipe_tmpdir = /tmp > antispam_spam_pattern_ignorecase = SPAM;JUNK > antispam_trash_pattern_ignorecase = trash;Deleted * > antispam_verbose_debug = 1 > quota = dict:user::file:/var/vmail/%d/%n/.quotausage > quota_rule2 = Trash:storage=+100M > quota_rule3 = Junk:ignore > quota_warning = storage=95%% quota-warning 95 %u %d > quota_warning2 = storage=80%% quota-warning 80 %u %d > quota_warning3 = -storage=100%% quota-below below %u %d > sieve = /var/vmail/%d/%n/.sieve > } > protocols = imap pop3 > service auth { > unix_listener /var/spool/postfix/private/auth { > group = postfix > mode = 0660 > user = postfix > } > unix_listener auth-userdb { > group = vmail > mode = 0600 > user = vmail > } > user = root > } > service quota-below { > executable = script /usr/local/bin/quota-below.sh > user = vmail > } > service quota-warning { > executable = script /usr/local/bin/quota-warning.sh > user = vmail > } > ssl_cert = </etc/postfix/smtpd.cert > ssl_key = </etc/postfix/smtpd.key > userdb { > args = /etc/dovecot/dovecot-sql.conf > driver = sql > } > protocol imap { > mail_plugins = quota imap_quota antispam > } > protocol pop3 { > mail_plugins = quota > pop3_uidl_format = %08Xu%08Xv > } > protocol lda { > info_log_path = /var/log/dovecot-lda.log > log_path = /var/log/dovecot-lda-errors.log > mail_plugins = sieve quota > } > > > Thank you, > > -Ben
Joseph Tam
2013-Jun-20 21:58 UTC
[Dovecot] Calling dovecot-lda from within Antispam pipe script (bash) seems to have no effect
Ben Johnson writes:> It really boils-down to the fact that I can call the following on the > command-line and it functions as expected: > > su vmail -c '/usr/lib/dovecot/deliver -a "sa-training at example.com" -d > "sa-training at example.com" -m "Training.SPAM" -p > "/tmp/sendmail-msg-25794.txt"' > > Yet, when I attempt to do the exact same thing from within the pipe > script that Dovecot Antispam calls, I receive exit code 75 from > deliver/dovecot-lda and absolutely nothing is logged, with exception of > the information of which I'm already aware (logged to syslog).Have you also checked the environment variables? I think dovecot-lda gets some information from them. Also, it's possible the PATH or some other critical environment variables is different, causing the difference in outcome. Joseph Tam <jtam.home at gmail.com>
Joseph Tam
2013-Jun-22 00:56 UTC
[Dovecot] Calling dovecot-lda from within Antispam pipe script (bash) seems to have no effect
Ben Johnson <ben at indietorrent.org> writes:> I added debugging output to the script, which now prints the environment > variables. My script now outputs the following: > ... > CONFIG_FILE=/var/run/dovecot/config > ... > Does anything jump-out at you?You didn't provide the analogous output from the interactive shell to see the differences (for example, USER might be being used), but from your later strace, I guess CONFIG_FILE has something to do with it. These threads seems relevant http://www.dovecot.org/list/dovecot/2011-May/059127.html http://www.mail-archive.com/dovecot at dovecot.org/msg38349.html That thread poster solved his problem by commenting out service imap-postlogin { # user = $default_internal_user ... } but I have no idea if it works, or whether it's a good idea, for your case. More docs http://wiki2.dovecot.org/PostLoginScripting Joseph Tam <jtam.home at gmail.com>
Maybe Matching Threads
- antispam plugin, pipe backend, how to make it work?
- [SERVERBUG] failed to send mail with SA and antispam plugin
- Exit status code 134; what is it, in the context of Dovecot Antispam plug-in?
- dovecot-antispam: pipe backend with spamc failing to parse args
- antispam plugin pipe script seems not to be called when it "should be"