Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions rootfs/etc/dovecot/conf.d/90-sieve.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ sieve_plugins {
}

# Personal scripts (was: sieve = ... / sieve_dir = ...)
# With SQL they live in the user's home, which the userdb builds from the
# mailbox's maildir, so they sit with the user's mail. LDAP keeps the fixed
# path, because an LDAP userdb only has a home when LDAP_DOVECOT_USER_ATTRS
# sets one.
sieve_script personal {
type = personal
driver = file
{{ if eq .DBDRIVER "ldap" }}
path = /var/mail/vhosts/%{user | domain}/%{user | username}/sieve
active_path = /var/mail/vhosts/%{user | domain}/%{user | username}/.dovecot.sieve
{{ else }}
path = ~/sieve
active_path = ~/.dovecot.sieve
{{ end }}
}

# Used when the user has no script of their own (was: sieve_default)
Expand Down
1 change: 1 addition & 0 deletions rootfs/usr/local/bin/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ _envtpl /etc/dovecot/conf.d/15-lda.conf
_envtpl /etc/dovecot/conf.d/20-imap.conf
_envtpl /etc/dovecot/conf.d/20-lmtp.conf
_envtpl /etc/dovecot/conf.d/90-quota.conf
_envtpl /etc/dovecot/conf.d/90-sieve.conf

_envtpl /etc/rspamd/local.d/redis.conf
_envtpl /etc/rspamd/local.d/settings.conf
Expand Down
31 changes: 31 additions & 0 deletions test/sieve.bats
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,34 @@ load 'test_helper/bats-assert/load'
assert_success
assert_output 1
}

# A mailbox whose maildir is not <domain>/<localpart>/, as PostfixAdmin writes
# it with domain_path = NO (#109). Its personal scripts belong in its home,
# next to its mail, not in /var/mail/vhosts/<domain>/<localpart>/.
SIEVE_HOME=/var/mail/vhosts/sieve.home@domain.tld

@test "checking dovecot: personal sieve scripts are stored in the user's home (non-default maildir)" {
run docker exec mariadb mysql -upostfix -ptestpasswd postfix -e "INSERT INTO mailbox (username, password, name, maildir, quota, local_part, domain, created, modified, active) SELECT 'sieve.home@domain.tld', password, 'Sieve HOME', 'sieve.home@domain.tld/', 1024000, 'sieve.home', 'domain.tld', NOW(), NOW(), 1 FROM mailbox WHERE username = 'john.doe@domain.tld'"
assert_success
run docker exec -i mailserver_sieve doveadm sieve put -a -u sieve.home@domain.tld filter <<'SIEVE'
require ["fileinto", "mailbox"];
fileinto :create "Filtered";
SIEVE
assert_success
run docker exec mailserver_sieve test -f $SIEVE_HOME/sieve/filter.sieve
assert_success
run docker exec mailserver_sieve readlink -f $SIEVE_HOME/.dovecot.sieve
assert_output "$SIEVE_HOME/sieve/filter.sieve"
run docker exec mailserver_sieve test -e /var/mail/vhosts/domain.tld/sieve.home
assert_failure
}

@test "checking dovecot: personal sieve script in the user's home filters delivered mail (non-default maildir)" {
docker exec mailserver_sieve /bin/sh -c "printf 'Subject: sieve home\n\nbody\n' | sendmail -f john.doe@domain.tld sieve.home@domain.tld"
for i in $(seq 60); do
[ "$(docker exec mailserver_sieve /bin/sh -c "ls $SIEVE_HOME/mail/.Filtered/new 2>/dev/null | wc -l")" -ge 1 ] && break
sleep 1
done
run docker exec mailserver_sieve /bin/sh -c "ls $SIEVE_HOME/mail/.Filtered/new | wc -l"
assert_output 1
}