Bug 38469

Summary: Default SIEVE script for Dovecot
Product: UCS Reporter: Daniel Tröder <troeder>
Component: Mail - DovecotAssignee: Daniel Tröder <troeder>
Status: CLOSED FIXED QA Contact: Sönke Schwardt-Krummrich <schwardt>
Severity: normal    
Priority: P5 CC: najjar, schwardt, walkenhorst
Version: UCS 4.0   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
What kind of report is it?: --- What type of bug is this?: ---
Who will be affected by this bug?: --- How will those affected feel about the bug?: ---
User Pain: Enterprise Customer affected?:
School Customer affected?: ISV affected?:
Waiting Support: Flags outvoted (downgraded) after PO Review:
Ticket number: Bug group (optional):
Max CVSS v3 score:
Bug Depends on:    
Bug Blocks: 34839, 38458, 38660    

Description Daniel Tröder univentionstaff 2015-05-06 18:51:47 CEST
Put UCS default spam SIEVE script either into "sieve_default" or create (like currently for Cyrus) a script for each user. Depends on how the editing works: The content of the "default personal sieve script" might not be visible to users, so they cannot copy the spam-sorting-part.
Comment 1 Daniel Tröder univentionstaff 2015-05-08 22:30:30 CEST
Commit is in 60614.

Default script is installed/modified by univention-dovecot-mkdefaultsieve.py, triggered by mail/antispam/requiredhits and mail/dovecot/folder/spam into /var/lib/dovecot/sieve/default.sieve.
Upon access it will automatically be compiled into a binary when the script file is newer than the binary.

Tested with Horde: users sees the default script and when editing or adding, it will be copied into their script, which will be used from that moment on - perfect.

Must still be tested with OX.
Comment 2 Daniel Tröder univentionstaff 2015-05-12 12:11:19 CEST
Correction: In Horde the default script cannot be seen either. It's just that univention-mail-horde/conffiles/etc/horde/ingo/prefs.d/10-ucs.php installed a SIEVE script that looks exactly the same.

OX ignores the default script and starts a new script from scratch. The user never sees the default script.

With Cyrus and OX the same happens though, because automatic spam sorting with SIEVE is disabled:
univention-mail-cyrus-ox/debian/univention-mail-cyrus-ox.postinst sets mail/cyrus/sieve/spam=no

Options I see from here on:
* leave as sieve_default script, leaving it up to Apps or users to deal with it, if they choose to modify their filters
* install the same SIEVE script into each users sieve directory upon user creation
* set the spam-sort-script as "sieve_before" script, that Dovecot will run before the users script. The user will not be able to see or to deactivate it. This is IMO what users expect. Make this a bool-UCRV for admins to deactivate it if they don't like it. They can already configure the target folder as well as the Spam-Level that will trigger sorting.
Comment 3 Sönke Schwardt-Krummrich univentionstaff 2015-05-20 11:43:58 CEST
(In reply to Daniel Tröder from comment #2)
> * install the same SIEVE script into each users sieve directory upon user
> creation

As discussed, we should stick to this variant and try to upload the script via SIEVE protocol if possible.
Comment 4 Daniel Tröder univentionstaff 2015-05-21 12:37:15 CEST
With r60815, the default SIEVE script will be installed into the users sieve directory upon mail-account creation. If a sieve folder exists already (user gets assigned an existing mailbox), nothing will be done.
Comment 5 Sönke Schwardt-Krummrich univentionstaff 2015-06-12 10:36:37 CEST
The listener module does currently not react on mail/dovecot/sieve/spam=no.
A default sieve script is always created regardless of the UCR settings. This has to be fixed.
Comment 6 Daniel Tröder univentionstaff 2015-06-12 15:20:15 CEST
Commit 61219 adds a UCRV mail/dovecot/sieve/spam to switch Sieve scipt generation for new users on/off.
Comment 7 Daniel Tröder univentionstaff 2015-06-17 11:57:01 CEST
Mail-Test found that folder "Spam" was created, but sieve tries to deliver to "INBOX/Spam". If sieve script target folder doesn't exist, mail will be delivered to INBOX.
Comment 8 Daniel Tröder univentionstaff 2015-06-17 12:19:29 CEST
Commit 61315 fixes the spam folder path in the default sieve script and makes sieve create it in case it doesn't exist. Dovecot would do that too, as the spam folder is also configured for autocreation in /etc/dovecot/conf.d/15-mailboxes.conf , but in the case it was reconfigured and dovecot was not yet reloaded (kind of a race condition) it'd still work.
Comment 9 Daniel Tröder univentionstaff 2015-06-18 12:06:30 CEST
Commit 61365 disables the "sieve_default" setting, as it was sorting spam even if disabled by mail/dovecot/sieve/spam.
Comment 10 Sönke Schwardt-Krummrich univentionstaff 2015-07-01 15:00:07 CEST
(In reply to Daniel Tröder from comment #6)
> Commit 61219 adds a UCRV mail/dovecot/sieve/spam to switch Sieve scipt
> generation for new users on/off.

Tested via 40_mail/31_sieve_script

(In reply to Daniel Tröder from comment #7)
> Mail-Test found that folder "Spam" was created, but sieve tries to deliver
> to "INBOX/Spam". If sieve script target folder doesn't exist, mail will be
> delivered to INBOX.

Covered by 40_mail/31_sieve_script

(In reply to Daniel Tröder from comment #8)
> Commit 61315 fixes the spam folder path in the default sieve script and
> makes sieve create it in case it doesn't exist. Dovecot would do that too,
> as the spam folder is also configured for autocreation in
> /etc/dovecot/conf.d/15-mailboxes.conf , but in the case it was reconfigured
> and dovecot was not yet reloaded (kind of a race condition) it'd still work.

OK

(In reply to Daniel Tröder from comment #9)
> Commit 61365 disables the "sieve_default" setting, as it was sorting spam
> even if disabled by mail/dovecot/sieve/spam.

OK

VERIFIED
Comment 11 Janek Walkenhorst univentionstaff 2015-07-09 18:13:08 CEST
<http://errata.univention.de/ucs/4.0/237.html>