Sieve vacation

Marco Colombo cyrus-list at
Wed Aug 1 04:34:37 EDT 2007

Ethariel wrote:
> Hello,
> I've installed cyrus-imapd (2.2.13 on MDV 2007). Sieve scripts are
> working fine except 'vacation'.
> User 1 has a vacation script with days: 1
> User 2 sents an email to user1 it receives an answer (the correct
> vacation message).
> Then after User2 can send email the same day or three days after, it
> will not receive anymore automatic answer.
> If I delete user1 script, and recreate a new one with another vacation
> alert, then it works fine for one more mail.
> The Sieve draft describes 'Day' as the period between two answers, but
> this value can be bypass by 'SITE' value.
> Where do I check site value ? Or are they any known bugs in 2.2.13 Sieve
> implementation ?
> (I've searched the archive without success).
> Thks to all
> Ethariel

I've been hit by the same problem, recently. I've positively verified
that sieve pushed an entry into the deliverdb (which is used to remember
 whom the autoresponse has already been sent to) with a timestamp of
(now + 3 days) instead of +1.

I've been digging through the source, both of 2.2.12 (which I'm running)
and of 2.3.8. The current minimum for :days seems to be hardcoded to 3 days.

I'm not totally sure this is intented, tho. It smells like an 'unwanted
feature'. Here's what I've found:

- in the sieve source, you've got a function named
sieve_register_vacation(), which take a C struct as an argument. This
struct has 4 member, of which two have inspiring names: min_response and
max_response. The relevant part of the code follows:

    if (v->min_response == 0) v->min_response = 3;
    if (v->max_response == 0) v->max_response = 90;

so, if the caller doesn't specify a min_response, the default is 3.
We're here inside the sieve parser, so this min_response is what
according to the RFC is a limit set by the implementation, and it's
totally fine, per spec, for the parser to accept an user script with
:days 1 but set it to the minimum value, 3.
You can see the source here:

- in the same place you find the source of sievec, which is the
command-line compiler for sieve scripts. This program only parses and
compliles a sieve script, and never actually executes it. Sieve scripts
are executed by lmtpd (part of the cyrus imapd), as a step of the
delivery process. Inside sievec.c you find:

sieve_vacation_t vacation = {
    0,				/* min response */
    0,				/* max response */
    (sieve_callback *) &foo,	/* autorespond() */
    (sieve_callback *) &foo	/* send_response() */

The foo() function is a dummy one, the two callback are called only at
execution time, not at parse/compile time, of course. Note that as far
as sievec is concerned, it does not specify limits, so the library
defaults, 3 and 90, come into play.

- in the cyrus-imapd source, you find timsieved, which provides a way
for remote users to update their sieve scripts. It seems it does not use
sievec to compile the script, it links to the sieve library instead.
Unsurprisingly, you see:

sieve_vacation_t vacation = {
    0,				/* min response */
    0,				/* max response */
    (sieve_callback *) &foo,	/* autorespond() */
    (sieve_callback *) &foo	/* send_response() */

Scripts are compiled by timsieved exactly in the same way sievec does.

- now the fun starts. There's another place where you can find a sieve
parser. It's inside lmtpd. If I'm not mistaken, this parser is not used
to parse/compile scripts, as lmtpd now looks for pre-compiled scripts
only. Anyway there is it, and it also calls sieve_register_vacation(),
but now the struct is different:

/* vacation support */
sieve_vacation_t vacation = {
    1,				/* min response */
    31,				/* max response */
    &autorespond,		/* autorespond() */
    &send_response,		/* send_response() */

Now, I think this struct is not actually been used any more. But it's
interesting to note that here the min response is set to 1. This
overrides the library default, and becomes the new implementation minimum.


I'd hardly call this a bug, but suspect that originally the intended
behaviour of sieve inside lmtpd (that is, cyrus imapd), was to set the
minimum of :days to 1, and not 3. By moving to precompiled scripts, this
 setting has been lost, since all the other compilers now relay on the
library default, which is 3.

Of course I'm not much familiar with all the source, and I may be
missing something.


More information about the Info-cyrus mailing list