autosieve compilation ignores sieve_extensions setting

James Ralston qralston+ml.info-cyrus at andrew.cmu.edu
Mon Dec 10 21:07:44 EST 2007


Hello University of Athens NOC Development Team,

First, thanks for the Cyrus imapd autocreate patches; they've proven
to be very useful.

I noticed there is a bug in the is_script_parsable() function.
Specifically, is_script_parsable() does not obey the
"sieve_extensions" setting in imapd.conf(5); instead, it registers a
predefined list of sieve functions.  This can lead to two problems:

1.  is_script_parsable() can reject as invalid a sieve script that
    sieve_generate_bytecode() has no issues with.

2.  is_script_parsable() can accept as valid a sieve script that
    sieve_generate_bytecode() will fail.

As an example of #1, consider these imapd.conf(5) settings:

sieve_extensions: copy envelope fileinto imapflags include notify regex relational subaddress vacation
autosievefolders: Junk
autocreate_sieve_script: /usr/share/cyrus-imapd/sieve/default

Let's say that /usr/share/cyrus-imapd/sieve/default contains:

    require ["include"];
    include :global "spam-auto-file";

This script is valid, because sieve_extensions contains "include", but
is_script_parsable() rejects it, because it doesn't register the
include function:

Dec 10 20:02:02 example imap[14059]: autocreate_sieve: Error while parsing script script errors: line 1: unsupported feature .

As an example of #2, note that since we deliberately exclude "reject"
from sieve_extensions (users always seem to want to use it to reject
spam, which is very bad, because doing so generates backscatter), a
script that calls reject will fail, even though is_script_parsable()
will pass it.

It's possible to work around this bug by compiling the Sieve script in
advance with sievec, and then setting (e.g.):

autocreate_sieve_script: /usr/share/cyrus-imapd/sieve/default
autocreate_sieve_compiledscript: /usr/share/cyrus-imapd/sieve/default.bc

This does the right thing; the user gets the byte-compiled version of
the script installed and activated, but also gets the plain-text
version (so they can edit it to customize it).  And it's arguably
better to do it this way, as then one eliminates the overhead of
performing the byte-compile for all newly-created Inboxes.

But, still, is_script_parsable() really should obey the
sieve_extensions setting...

Is this a known issue?  If not, although we are in the process of
migrating from Cyrus to Exchange (alas), I think I could come up
with a patch for this without too much difficulty...



More information about the Info-cyrus mailing list