Getting an extprogram script to work
Hi all,
I'm trying to do the same thing everyone else is: having rspamd learn_ham or learn_spam depending on where I move a message. My current problem is that Dovecot seems to be reporting success, but nothing ever happens -- the script somehow fails to run.
I'm currently using a dummy script that just writes a file to /tmp, until I can get this much working, at least. My bin_dir:
me@server:/usr/lib/dovecot/sieve# ls -l total 40 drwxr-xr-x 2 root root 4096 Jan 21 03:35 ./ drwxr-xr-x 4 root root 12288 Aug 29 06:28 ../ -rw-r--r-- 1 root root 112 Jan 21 02:17 report-ham.sieve -rw-r--r-- 1 root root 250 Jan 21 02:17 report-ham.svbin -rw-r--r-- 1 root root 112 Jun 3 2019 report-spam.sieve -rw-r--r-- 1 root root 258 Jun 3 2019 report-spam.svbin -rwxr-xr-x 1 root root 105 Jan 21 03:35 rspamd_ham.sh* -rwxr-xr-x 1 root root 43 Jun 3 2019 rspamd_spam.sh*
Then the report-ham.sieve script:
require ["vnd.dovecot.pipe", "copy", "imapsieve", "fileinto"];
pipe :copy "rspamd_ham.sh";
#fileinto "INBOX";
And the dummy rspamd_ham.sh script:
#!/bin/bash
#exec /usr/bin/rspamc learn_ham
tim=date +%M-%S
echo "${1}" > "/tmp/${tim}_results.txt"
I can confirm the above script works correctly when run from the command line, both as root and the vmail user. When run as part of the sieve process, no errors are reported, but no file is created under /tmp. From the logs:
Debug: sieve: Sieve imapsieve plugin for Pigeonhole version 0.4.21 (92477967) loaded
Debug: sieve: Sieve Extprograms plugin for Pigeonhole version 0.4.21 (92477967) loaded
...
Debug: learn/ham: Mailbox opened because: SELECT
Debug: imapsieve: mailbox learn/ham: APPEND event
Debug: imapsieve: Matched static mailbox rule [1]
Debug: sieve: file storage: Using Sieve script path: /usr/lib/dovecot/sieve/report-ham.sieve
Debug: sieve: file script: Opened script report-ham' from
/usr/lib/dovecot/sieve/report-ham.sieve'
Debug: sieve: Opening script 1 of 1 from /usr/lib/dovecot/sieve/report-ham.sieve' Debug: sieve: Loading script /usr/lib/dovecot/sieve/report-ham.sieve Debug: sieve: Script binary /usr/lib/dovecot/sieve/report-ham.svbin successfully loaded Debug: sieve: binary save: not saving binary /usr/lib/dovecot/sieve/report-ham.svbin, because it is already stored Debug: sieve: Executing script from
/usr/lib/dovecot/sieve/report-ham.svbin'
Debug: sieve: action pipe: running program: rspamd_ham.sh
Debug: Mailbox learn/ham: Opened mail UID=249 because: mail stream
Debug: waiting for program /usr/lib/dovecot/sieve/rspamd_ham.sh' to finish after 0 msecs sieve: pipe action: piped message to program
rspamd_ham.sh'
Debug: learn/ham: Mailbox opened because: lib-lda delivery
sieve: left message in mailbox 'learn/ham'
Near as I can tell, the first time this runs after a dovecot restart, I get this error instead:
Error: write(program stdin) failed: Broken pipe Error: sieve: pipe action: failed to program `rspamd_ham.sh': refer to server log for more information.
But that only happens once, then it behaves as above.
The "Opened mail UID=XXX" bit changes UID (increments monotonically?) every time.
I think that ought to be everything but my dovecot -n. Thanks in advance for any help.
# 2.2.33.2 (d6601f4ec): /etc/dovecot/dovecot.conf # Pigeonhole version 0.4.21 (92477967) # OS: Linux 4.15.0-1057-aws x86_64 Ubuntu 18.04.3 LTS ext4 auth_mechanisms = plain login auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@+ lda_mailbox_autocreate = yes lda_mailbox_autosubscribe = yes lmtp_save_to_detail_mailbox = yes mail_debug = yes mail_home = /var/mail/vmail/%d/%n mail_location = maildir:/var/mail/vmail/%d/%n/mail:LAYOUT=fs mail_plugins = " quota" mail_prefetch_count = 20 mail_privileged_group = mail mailbox_list_index = yes managesieve_notify_capability = mailto managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttext imapsieve vnd.dovecot.imapsieve namespace inbox { inbox = yes location = mailbox Drafts { special_use = \Drafts } mailbox Junk { special_use = \Junk } mailbox Sent { special_use = \Sent } mailbox "Sent Messages" { special_use = \Sent } mailbox Trash { special_use = \Trash } prefix = } passdb { args = scheme=ssha512 username_format=%u /etc/dovecot/passwd.db driver = passwd-file } plugin { imapsieve_mailbox1_before = file:/usr/lib/dovecot/sieve/report-ham.sieve imapsieve_mailbox1_causes = APPEND imapsieve_mailbox1_name = learn/ham quota_rule = *:storage=5G quota_rule2 = Trash:ignore quota_rule3 = Junk:ignore quota_status_nouser = DUNNO quota_status_overquota = 552 5.2.2 Mailbox is full quota_status_success = DUNNO recipient_delimiter = + sieve = file:~/sieve;active=~/.dovecot.sieve sieve_after = /var/mail/vmail/sieve-after sieve_before = /var/mail/vmail/sieve-before sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.environment +vnd.dovecot.debug sieve_pipe_bin_dir = /usr/lib/dovecot/sieve sieve_plugins = sieve_imapsieve sieve_extprograms } protocols = " imap lmtp sieve" quota_full_tempfail = yes service auth { unix_listener /var/spool/postfix/private/dovecot-auth { mode = 0666 } } service lmtp { unix_listener /var/spool/postfix/private/dovecot-lmtp { mode = 0666 user = vmail } } service managesieve-login { inet_listener sieve { port = 4190 } service_count = 1 } service quota-status { client_limit = 1 executable = quota-status -p postfix inet_listener { port = 12340 } } ssl = required ssl_cert =
participants (1)
-
Eric Abrahamsen