Repository navigation
Keep personal sieve scripts in the user's home with SQL (#109) - #112
Merged
Merged
Conversation
) The SQL userdb builds each user's home and mail_path from the mailbox's maildir column, but the personal sieve storage was fixed at /var/mail/vhosts/<domain>/<localpart>/. A mailbox whose maildir differs, such as one imported from a PostfixAdmin installation with domain_path = NO, kept its mail in one place and its filters in another, and scripts copied in with the mail were ignored. With SQL the storage is now ~/sieve and ~/.dovecot.sieve. Mailboxes created by the PostfixAdmin image have maildir = <domain>/<localpart>/, so their scripts stay where they are. LDAP keeps the fixed path, since an LDAP userdb only has a home when LDAP_DOVECOT_USER_ATTRS sets one. 90-sieve.conf is now rendered as a template.
SaraSmiseth
approved these changes
Dec 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #109
What is the current behavior (you can also link to an open issue here) ?
The SQL userdb sets each user's
homeandmail_pathfrom themaildircolumn (auth-sql.conf.ext:CONCAT('/var/mail/vhosts/',maildir)), but90-sieve.conffixes the personal sieve storage at/var/mail/vhosts/<domain>/<localpart>/. That only matches whenmaildiris<domain>/<localpart>/, which is what PostfixAdmin writes withdomain_path = 'YES'. Withdomain_path = 'NO',maildirisuser@domain/, so mail goes to/var/mail/vhosts/user@domain/while filters are read from and written to/var/mail/vhosts/<domain>/<localpart>/. Scripts copied in with the mail from another server are ignored.What is the new behavior (if this is a feature change) ?
path = ~/sieveandactive_path = ~/.dovecot.sieve, as the issue proposes. For a mailbox whosemaildiris<domain>/<localpart>/this is the same directory as before, so nothing moves.LDAP_DOVECOT_USER_ATTRSsets one, so~is not safe to rely on there.90-sieve.confis now rendered bysetup.sh(_envtpl) to choose between the two.Upgrade notes.
Who is not affected: setups using LDAP, and setups whose mailboxes were all created through the PostfixAdmin image (
mailserver2/postfixadmin, as indocker-compose.sample.yml). That image writesdomain_path = 'YES'anddomain_in_mailbox = 'NO'into its configuration on every start, and no environment variable changes them, so every mailbox it creates hasmaildir = <domain>/<localpart>/. For those mailboxes the new path is the same directory as the old one.Who may be affected: setups with mailboxes created some other way, for example a database imported from another PostfixAdmin installation, a different PostfixAdmin image or configuration, or rows written by a script. If such a mailbox's
maildiris not<domain>/<localpart>/and its user saved filters on this server (ManageSieve, Rainloop,doveadm sieve), those filters are still at the old path, and Dovecot no longer reads them. The container does not move them.To check: run this from the directory with your
docker-compose.yml, before or after upgrading. It asks Dovecot for every mailbox's home, so it works with MySQL/MariaDB and PostgreSQL alike and needs no database password:(Without Compose:
docker exec -i <mailserver container> sh -c '...', with the same script.)If it prints only
check finished, nothing needs doing. For each mailbox it lists, movesieve/and.dovecot.sievetogether from the first directory into the second..dovecot.sieveis a link intosieve/: a relative link keeps working after the move, an absolute one has to be re-pointed. An inactive mailbox is listed with its old directory only, because Dovecot does not look up its home; its new directory is/var/mail/vhosts/followed by itsmaildir.I left out an automatic move on startup. When the home already holds scripts, for example ones copied in with the mail as in Paths for personal sieve scripts should be based on the virtual users home directory #109, the container would have to pick which set wins. The check flags that case for a person to decide.
Type of change
Not breaking for mailboxes created by the PostfixAdmin image. It is a one-time manual step for mailboxes with a different
maildirthat already have filters here, as above.Status
Todo List
How has this been tested ?
Two tests added to
test/sieve.bats. They insert a mailbox withmaildir = sieve.home@domain.tld/, asdomain_path = 'NO'would, then:doveadm sieve put -aand check it lands in/var/mail/vhosts/sieve.home@domain.tld/sieve/,.dovecot.sievepoints at it, and nothing is created under/var/mail/vhosts/domain.tld/sieve.home;Filtered.On this branch (rebased on master
32a7ef9), fresh build,TEST_DNS=9.9.9.9:All nine suites: 364/364 (default 140, reverse 88, ldap 66, ldap2 30, sieve 4, ecdsa 4, traefik_acmev1 11, traefik_acmev2 12, traefik_v3 9).
The new tests against an image built from master (
32a7ef9): the storage test fails, because the script is not written under the mailbox'smaildir(test -f /var/mail/vhosts/sieve.home@domain.tld/sieve/filter.sieve, status 1). The delivery test passes there, because on master both the upload and the delivery use the old path, so they agree. It confirms the uploaded script actually filters mail, and leaves the location to the storage test.The upgrade check, run in a sieve-suite container (MariaDB), with five mailboxes set up by hand:
maildir, with filters: not listedmaildir, no filters: not listedmaildir, filters at the old path: listed with both directoriessieve/also present in its home: listed, plus the merge warningWith the old-path filters removed, it printed only
check finished. It ran throughdocker exec -i, notdocker compose exec -T.