[Dovecot] Pigeonhole: extprograms - pipe
Hello!
I've tried to use extprograms pipe feature but stuck with "Broken pipe" errors in mail log:
May 17 15:18:57 backend1 dovecot: lmtp(20338, user@domain.tld): Debug: 3VMVFWFKllFyTwAArRg8UA: sieve: action pipe: running program: learn May 17 15:18:57 backend1 dovecot: script: Error: write(response) failed: Broken pipe May 17 15:18:57 backend1 dovecot: lmtp(20338, user@domain.tld): 3VMVFWFKllFyTwAArRg8UA: sieve: execution of script /data/mail/storage/domain/user@domain.tld/.dovecot.sieve;name=main script failed, but implicit keep was successful (user logfile /data/mail/storage/domain/buser@domain.tld/.dovecot.sieve.log should reveal additional details)
/data/mail/storage/domain/buser@domain.tld/.dovecot.sieve.log: error: msgid=c7cd36f19be8164addf091a646b8b284@domain.tld: pipe action: failed to pipe message to program `learn': refer to server log for more information. [2013-05-17 15:18:57] ham user@domain.tld 50796.
Sieve script contents: require ["fileinto","copy","mailbox","vnd.dovecot.pipe"];
if anyof (header :is "Subject" "ham") { pipe :try "learn" ["ham"]; fileinto "INBOX/ham"; stop; }
Sieve plugin config uncommented conents: sieve_plugins = sieve_extprograms *sieve_pipe_socket_dir = sieve-pipe*
# Define the executed script as parameter to the sieve service executable = script /etc/dovecot/scripts/spam.sh
# Use some unprivileged user for executing the program user = nobody
# The unix socket located in the sieve_pipe_socket_dir (as defined in the # plugin {} section above) unix_listener sieve-pipe/learn { # LDA/LMTP must have access user = nobody mode = 0777 } }
spam.sh is message processing script which interacts with spamassassin. I've tested pipe with spam.sh that redirects stdin to /dev/null and returns 0 but errors were logged anyway. Note that spam.sh runs, getting the message from sieve and processing it to spamassassin without a problem, but "broken pipe" is being logged.
At 7PM +0400 on 17/05/13 you (Anes Mukhametov) wrote:
Hello!
I've tried to use extprograms pipe feature but stuck with "Broken pipe" errors in mail log:
May 17 15:18:57 backend1 dovecot: lmtp(20338, user@domain.tld): Debug: 3VMVFWFKllFyTwAArRg8UA: sieve: action pipe: running program: learn May 17 15:18:57 backend1 dovecot: script: Error: write(response) failed: Broken pipe
I suspect that what's happening here is that your script isn't reading the whole mail. However, that pipe that's broken is (I think) the socket from the script service back to the master service, so I don't quite understand how that could happen.
May 17 15:18:57 backend1 dovecot: lmtp(20338, user@domain.tld): 3VMVFWFKllFyTwAArRg8UA: sieve: execution of script /data/mail/storage/domain/user@domain.tld/.dovecot.sieve;name=main script failed, but implicit keep was successful (user logfile /data/mail/storage/domain/buser@domain.tld/.dovecot.sieve.log should reveal additional details)
/data/mail/storage/domain/buser@domain.tld/.dovecot.sieve.log: error: msgid=c7cd36f19be8164addf091a646b8b284@domain.tld: pipe action: failed to pipe message to program `learn': refer to server log for more information. [2013-05-17 15:18:57] ham user@domain.tld 50796.
Mmm, recursively-referential error logs. Always fun...
spam.sh is message processing script which interacts with spamassassin. I've tested pipe with spam.sh that redirects stdin to /dev/null and returns 0 but errors were logged anyway.
Well, you shouldn't do that: redirecting stdin from /dev/null in a shell script will close the incoming pipe, which means you won't read the mail at all and sieve will get upset. What you need to do instead (if you've got data to read and nothing to do with it) is 'cat >/dev/null', which will read it all and throw it away.
Note that spam.sh runs, getting the message from sieve and processing it to spamassassin without a problem, but "broken pipe" is being logged.
Hmm. Are you sure your real script is exitting with 0? spamc in learn mode exits 5 or 6 depending on whether the mail was already learned or not.
Ben
No result:
[root@backend1 scripts]# cat spam.sh #!/bin/bash
cat > /dev/null
exit 0 [root@backend1 scripts]#
In the log: May 17 22:42:56 backend1 dovecot: script: Error: write(response) failed: Broken pipe
:(
On Sat, May 18, 2013 at 2:05 AM, Ben Morrow ben@morrow.me.uk wrote:
At 7PM +0400 on 17/05/13 you (Anes Mukhametov) wrote:
Hello!
I've tried to use extprograms pipe feature but stuck with "Broken pipe" errors in mail log:
May 17 15:18:57 backend1 dovecot: lmtp(20338, user@domain.tld): Debug: 3VMVFWFKllFyTwAArRg8UA: sieve: action pipe: running program: learn May 17 15:18:57 backend1 dovecot: script: Error: write(response) failed: Broken pipe
I suspect that what's happening here is that your script isn't reading the whole mail. However, that pipe that's broken is (I think) the socket from the script service back to the master service, so I don't quite understand how that could happen.
May 17 15:18:57 backend1 dovecot: lmtp(20338, user@domain.tld): 3VMVFWFKllFyTwAArRg8UA: sieve: execution of script /data/mail/storage/domain/user@domain.tld/.dovecot.sieve;name=main script failed, but implicit keep was successful (user logfile /data/mail/storage/domain/buser@domain.tld/.dovecot.sieve.log should reveal additional details)
/data/mail/storage/domain/buser@domain.tld/.dovecot.sieve.log: error: msgid=c7cd36f19be8164addf091a646b8b284@domain.tld: pipe action: failed to pipe message to program `learn': refer to server log for more information. [2013-05-17 15:18:57] ham user@domain.tld 50796.
Mmm, recursively-referential error logs. Always fun...
spam.sh is message processing script which interacts with spamassassin. I've tested pipe with spam.sh that redirects stdin to /dev/null and returns 0 but errors were logged anyway.
Well, you shouldn't do that: redirecting stdin from /dev/null in a shell script will close the incoming pipe, which means you won't read the mail at all and sieve will get upset. What you need to do instead (if you've got data to read and nothing to do with it) is 'cat >/dev/null', which will read it all and throw it away.
Note that spam.sh runs, getting the message from sieve and processing it to spamassassin without a problem, but "broken pipe" is being logged.
Hmm. Are you sure your real script is exitting with 0? spamc in learn mode exits 5 or 6 depending on whether the mail was already learned or not.
Ben
On 5/18/2013 9:58 AM, Anes Mukhametov wrote:
No result:
[root@backend1 scripts]# cat spam.sh #!/bin/bash
cat > /dev/null
exit 0 [root@backend1 scripts]#
In the log: May 17 22:42:56 backend1 dovecot: script: Error: write(response) failed: Broken pipe
:(
I must say I haven't tested the use of the script service in a while and it is not part of the test suite. I've tried it at my end and I can reproduce the error.
I'll look at this more thoroughly tomorrow.
Regards,
Stephan.
On 5/18/2013 11:54 PM, Stephan Bosch wrote:
On 5/18/2013 9:58 AM, Anes Mukhametov wrote:
No result:
[root@backend1 scripts]# cat spam.sh #!/bin/bash
cat > /dev/null
exit 0 [root@backend1 scripts]#
In the log: May 17 22:42:56 backend1 dovecot: script: Error: write(response) failed: Broken pipe
:(
I must say I haven't tested the use of the script service in a while and it is not part of the test suite. I've tried it at my end and I can reproduce the error.
I'll look at this more thoroughly tomorrow.
This should fix it:
http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/d4e9ca7fddcf
Regards,
Stephan.
participants (3)
-
Anes Mukhametov
-
Ben Morrow
-
Stephan Bosch