[Dovecot] Sieve (randomly?) flagging messages as \\Seen \\Deleted

Emanuele Balla (aka Skull) skull at bofhland.org
Fri Apr 4 18:20:06 UTC 2014


On 04/04/14 18:31, Stephan Bosch wrote:

> Sieve doesn't add flags unless it is explicitly told to do so. The
> behavior you describe is therefore quite bizarre, especially since using
> removeflag seems to provide a workaround.

I know, or I wouldn't be so puzzled...


> What does your full Sieve script look like?

Mine is relatively long, although quite straightforward: just foldering
stuff in several places based on List-Id and applying Thunderbird
tags/labels based on a few conditions.

But the other user's one is way shorter:

require ["regex","fileinto"];
# rule:[rule0]
if anyof (header :contains "To" "XXX", header :contains "From" "xxx",
header :regex "Subject" "xxx", [...])
{
        fileinto "folder1";
	stop;
}
# rule:[rule1]
if anyof (header :contains "To" "YYY", header :contains "From" "YYY",
header :contains "Received" "YYY")
{
        fileinto "folder1";
        stop;
}


> What is your full configuration?

Not much longer than what I already provided...

# 2.1.7: /etc/dovecot/dovecot.conf
# OS: Linux 3.2.0-4-amd64 x86_64 Debian 7.4
auth_mechanisms = plain login
default_vsz_limit = 512 M
first_valid_gid = 8
first_valid_uid = 201
last_valid_gid = 8
last_valid_uid = 201
mail_plugins = mail_log notify
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 ihave vacation-seconds editheader
passdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
plugin {
  mail_debug = yes
  mail_log_events = flag_change save
  mail_log_fields = uid box msgid flags subject
  sieve = ~/.dovecot.sieve
  sieve_dir = ~/sieve
  sieve_extensions = +vacation-seconds +editheader
  sieve_vacation_default_period = 2d
  sieve_vacation_dont_check_recipient = yes
  sieve_vacation_max_period = 30d
  sieve_vacation_min_period = 2s
  sieve_vacation_use_original_recipient = no
}
postmaster_address = postmaster at bofhland.org
protocols = " imap lmtp sieve pop3"
service auth {
  unix_listener /var/spool/postfix/private/auth {
    mode = 0660
    user = postfix
  }
}
service imap-login {
  inet_listener imap {
    address = 127.0.0.1
    port = 143
  }
  inet_listener imaps {
    port = 993
    ssl = yes
  }
  process_min_avail = 0
}
service imap {
  idle_kill = 30 mins
  process_limit = 1024
  vsz_limit = 1 G
}
service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
    group = postfix
    mode = 0660
    user = postfix
  }
}
service managesieve-login {
  inet_listener sieve {
    address = 127.0.0.1
    port = 4190
  }
}
service pop3-login {
  inet_listener pop3s {
    port = 995
    ssl = yes
  }
}
ssl_cert = </etc/ssl/certs/mail.crt
ssl_cipher_list =
ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:DES-CBC3-SHA
ssl_key = </etc/ssl/private/mail.key
ssl_protocols = TLSv1
userdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
verbose_proctitle = yes
protocol lmtp {
  hostname = mail.bofhland.org
  mail_debug = yes
  mail_plugins = sieve mail_log notify
}
protocol imap {
  mail_max_userip_connections = 20
}


I can also provide the SQL query I'm using, if you wish, but all I
extract from the DB is home, maildir and quota (although this is not
used at the moment). UID and GID are statically assigned, as you can
also see from the "(first|last)_valid_(uid|gid)" in the config above.


Really, dovecot usage is quite trivial here.
The only "strange" thing is the fact that the LMTP process is provided
an hostname on its own.


> Do you perhaps return a sieve_before setting from userdb?

Nope.
Also, if there was one defined somehow/somewhere, I'd see something in
sieve's debug (when trying to open it, compiling, etc), but there's nothing.

I can tell more: searching for a global workaround, in the meanwhile I
added a sieve_before script (not shown in the config above) doing only this:

require ["imap4flags"];
removeflag "\\Deleted";
removeflag "\\Seen";


As a result, the problem disappeared for all users... :-|
(and yeah, the execution of this sieve_before appears in my debug logs, now)



More information about the dovecot mailing list