Using filter in an imapsieve script?

Tobi tobster at brain-force.ch
Thu Apr 6 11:47:00 EEST 2017


To further debug I wrote a little shell wrapper for my gpgit script.
That wrapper now is called from imap sieve script.
The wrapper writes exit code of gpgit and the mail content returned by
gpgit into a logfile. I can see that gpgit returns 0 and the mail
content returned is encrypted.
But still the mail that appears in sent mailbox is NOT encrypted. How
can that be?
It seems that for what reason ever the mail is stored as it's passed to
the filter and not how it's returned by filter.
Any idea whats going on?

Thanks for any idea how to solve this issue

tobi

Am 06.04.2017 um 08:31 schrieb Tobi:
> Hi Stephan
>
> yes the imap_sieve plugin is added to the mail_plugins for imap.
> Thanks for the hint with mail_debug. After enabling it I can see that
> the program seems to be called, so filter should not be the problem.
> But the result is that the message appears unencrypted in my sent folder
>
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> imapsieve: mailbox Sent: APPEND event
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> sieve: Pigeonhole version 0.4.16 (fed8554) initializing
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> sieve: include: sieve_global is not set; it is currently not possible to
> include `:global' scripts.
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> sieve: Sieve imapsieve plugin for Pigeonhole version 0.4.16 (fed8554) loaded
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> sieve: Sieve Extprograms plugin for Pigeonhole version 0.4.16 (fed8554)
> loaded
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> imapsieve: Static mailbox rule [1]: mailbox=`Spam' from=`*'
> causes=(COPY) =>
> before=`file:/home/vmail/brain-force.ch/tobster/dovecot-mail-filter.sieve'
> after=(none)
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> imapsieve: Static mailbox rule [2]: mailbox=`Sent' from=`*' causes=(COPY
> APPEND) =>
> before=`file:/home/vmail/brain-force.ch/tobster/dovecot-crypt-sent.sieve'
> after=(none)
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> imapsieve: Matched static mailbox rule [2]
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> sieve: file storage: Using active Sieve script path:
> /home/vmail/brain-force.ch/tobster/.dovecot.sieve
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> sieve: file storage: Using script storage path:
> /home/vmail/brain-force.ch/tobster/sieve
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> sieve: file storage: Relative path to sieve storage in active link: sieve/
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> sieve: file storage: Using Sieve script path:
> /home/vmail/brain-force.ch/tobster/dovecot-crypt-sent.sieve
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> sieve: file script: Opened script `dovecot-crypt-sent' from
> `/home/vmail/brain-force.ch/tobster/dovecot-crypt-sent.sieve'
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> sieve: Opening script 1 of 1 from
> `/home/vmail/brain-force.ch/tobster/dovecot-crypt-sent.sieve'
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> sieve: Loading script
> /home/vmail/brain-force.ch/tobster/dovecot-crypt-sent.sieve
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> sieve: Script binary
> /home/vmail/brain-force.ch/tobster/dovecot-crypt-sent.svbin successfully
> loaded
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> sieve: binary save: not saving binary
> /home/vmail/brain-force.ch/tobster/dovecot-crypt-sent.svbin, because it
> is already stored
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> sieve: Executing script from
> `/home/vmail/brain-force.ch/tobster/dovecot-crypt-sent.svbin'
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> sieve: action filter: running program: gpgit
>> Apr  6 08:20:26 mbox2 dovecot: imap(tobster at brain-force.ch): Debug:
> Mailbox Sent: Opened mail UID=3800 because: mail stream
>
> From my understanding the logs looks fine. Just here
>
>> Debug: sieve: action filter: running program: gpgit
> I wonder if the parameter given to gpgit should be logged as well?
> Calling gpgit without the userparameter would explain why the message
> appears unencrypted in sent mailbox.
>
>
> Best regards
>
>
> tobi
>
> Am 06.04.2017 um 00:58 schrieb Stephan Bosch:
>> Op 4/5/2017 om 11:48 AM schreef Tobi:
>>> Hello list
>>>
>>> I currently have an issue with an imapsieve script on my dovecot server
>>>
>>> CentOS Linux release 7.3.1611 (Core)
>>> Dovecot 2.2.26.0 (23d1de6)
>>> Pigeonhole 2.2.26.0
>>>
>>> The goal is to "fire" an imapsieve script upon mailclient saves message
>>> to sent folder
>>> I setup the following in 90-plugin.conf:
>>>
>>> plugin {
>>>     sieve_plugins = sieve_imapsieve sieve_extprograms
>>>     sieve_extensions = +vnd.dovecot.filter +vnd.dovecot.pipe
>>> +vnd.dovecot.execute
>>>     sieve_filter_bin_dir = /etc/dovecot/sieve-filters
>>>     sieve_pipe_bin_dir = /etc/dovecot/sieve-filters
>>>     sieve_execute_bin_dir = /etc/dovecot/sieve-filters
>>>     sieve_filter_exec_timeout = 10000
>>>     sieve_pipe_exec_timeout = 10000
>>>     sieve_execute_exec_timeout = 10000
>>>     imapsieve_mailbox1_name = Sent
>>>     imapsieve_mailbox1_causes = COPY APPEND
>>>     imapsieve_mailbox1_before =
>>> file:/home/vmail/domain/user/dovecot-crypt-sent.sieve
>>> }
>>>
>>> and the content of the sieve script is:
>>>
>>> require ["environment", "vnd.dovecot.filter", "variables", "imapsieve",
>>> "vnd.dovecot.pipe", "vnd.dovecot.execute"];
>>>
>>> if anyof (environment :is "imap.cause" "APPEND", environment :is
>>> "imap.cause" "COPY") {
>>>   filter "gpgit" "myuser at mydomain.tld";
>>> }
>>>
>>> gpgit is a perl script that encrypts a given message using the users pub
>>> key and returns back the encrypted message
>>> As a sieve script for lmtp/lda it works fine and encrypted messages show
>>> up in the mailbox. But it does not work if it is used as imap sieve script
>>> There is nothing in the logs that indicates a problem with the imap
>>> sieve script.
>>> Is it possible that 'filter' is not supported for imapsieve as it
>>> changes the content of a message?
>>>
>>> Thanks for any hint
>> Did you add the imap_sieve plugin to mail_plugins for imap?
>>
>> Once you enable mail_debug, your logs should show Sieve activity in imap.
>>
>> Regards,
>>
>> Stephan.




More information about the dovecot mailing list