diff --git a/target/dovecot/10-mail.conf b/target/dovecot/10-mail.conf index 055186cd..f91fd1b2 100644 --- a/target/dovecot/10-mail.conf +++ b/target/dovecot/10-mail.conf @@ -27,6 +27,7 @@ # # # +mail_home = /var/mail/%d/%n/home/ mail_location = maildir:/var/mail/%d/%n # If you need to set multiple mailbox locations or want to change default diff --git a/target/dovecot/auth-master.inc b/target/dovecot/auth-master.inc index b71967cb..daebb392 100755 --- a/target/dovecot/auth-master.inc +++ b/target/dovecot/auth-master.inc @@ -6,4 +6,3 @@ passdb { result_success = continue #auth_bind = yes } - diff --git a/target/dovecot/auth-passwdfile.inc b/target/dovecot/auth-passwdfile.inc index d05c9abb..6bbf8258 100644 --- a/target/dovecot/auth-passwdfile.inc +++ b/target/dovecot/auth-passwdfile.inc @@ -15,5 +15,5 @@ passdb { userdb { driver = passwd-file args = username_format=%u /etc/dovecot/userdb - default_fields = uid=docker gid=docker home=/var/mail/%d/%u + default_fields = uid=docker gid=docker home=/var/mail/%d/%u/home/ } diff --git a/target/scripts/helpers/accounts.sh b/target/scripts/helpers/accounts.sh index 996e6896..6ea1acbd 100644 --- a/target/scripts/helpers/accounts.sh +++ b/target/scripts/helpers/accounts.sh @@ -77,7 +77,7 @@ function _create_accounts # Dovecot's userdb has the following format # user:password:uid:gid:(gecos):home:(shell):extra_fields - DOVECOT_USERDB_LINE="${LOGIN}:${PASS}:5000:5000::/var/mail/${DOMAIN}/${USER}::${USER_ATTRIBUTES}" + DOVECOT_USERDB_LINE="${LOGIN}:${PASS}:5000:5000::/var/mail/${DOMAIN}/${USER}/home::${USER_ATTRIBUTES}" if grep -qF "${DOVECOT_USERDB_LINE}" "${DOVECOT_USERDB_FILE}" then _log 'warn' "Login '${LOGIN}' will not be added to '${DOVECOT_USERDB_FILE}' twice" @@ -85,12 +85,12 @@ function _create_accounts echo "${DOVECOT_USERDB_LINE}" >>"${DOVECOT_USERDB_FILE}" fi - mkdir -p "/var/mail/${DOMAIN}/${USER}" + mkdir -p "/var/mail/${DOMAIN}/${USER}/home" # copy user provided sieve file, if present if [[ -e "/tmp/docker-mailserver/${LOGIN}.dovecot.sieve" ]] then - cp "/tmp/docker-mailserver/${LOGIN}.dovecot.sieve" "/var/mail/${DOMAIN}/${USER}/.dovecot.sieve" + cp "/tmp/docker-mailserver/${LOGIN}.dovecot.sieve" "/var/mail/${DOMAIN}/${USER}/home/.dovecot.sieve" fi done < <(_get_valid_lines_from_file "${DATABASE_ACCOUNTS}") diff --git a/target/scripts/startup/setup.d/dovecot.sh b/target/scripts/startup/setup.d/dovecot.sh index 60a04a6c..be9b71c2 100644 --- a/target/scripts/startup/setup.d/dovecot.sh +++ b/target/scripts/startup/setup.d/dovecot.sh @@ -24,10 +24,10 @@ function _setup_dovecot ( 'sdbox' | 'mdbox' ) _log 'trace' "Dovecot ${DOVECOT_MAILBOX_FORMAT} format configured" - sed -i -e \ - "s|^mail_location = .*$|mail_location = ${DOVECOT_MAILBOX_FORMAT}:\/var\/mail\/%d\/%n|g" \ + sedfile -i -E "s|^(mail_home =).*|\1 /var/mail/%d/%n|" /etc/dovecot/conf.d/10-mail.conf + sedfile -i -E \ + "s|^(mail_location =).*|\1 ${DOVECOT_MAILBOX_FORMAT}:/var/mail/%d/%n|" \ /etc/dovecot/conf.d/10-mail.conf - _log 'trace' 'Enabling cron job for dbox purge' mv /etc/cron.d/dovecot-purge.disabled /etc/cron.d/dovecot-purge chmod 644 /etc/cron.d/dovecot-purge @@ -35,7 +35,6 @@ function _setup_dovecot ( * ) _log 'trace' 'Dovecot default format (maildir) configured' - sed -i -e 's|^mail_location = .*$|mail_location = maildir:\/var\/mail\/%d\/%n|g' /etc/dovecot/conf.d/10-mail.conf ;; esac diff --git a/test/tests/parallel/set1/dovecot/dovecot_sieve.bats b/test/tests/parallel/set1/dovecot/dovecot_sieve.bats index c4b0112f..c2e9e6c7 100644 --- a/test/tests/parallel/set1/dovecot/dovecot_sieve.bats +++ b/test/tests/parallel/set1/dovecot/dovecot_sieve.bats @@ -17,9 +17,9 @@ function setup_file() { --env ENABLE_MANAGESIEVE=1 # Required for mail delivery via nc: --env PERMIT_DOCKER=container - # Mount into mail dir for user1 to treat as a user-sieve: + # Mount into home dir for user1 to treat as a user-sieve: # NOTE: Cannot use ':ro', 'start-mailserver.sh' attempts to 'chown -R' /var/mail: - --volume "${TEST_TMP_CONFIG}/dovecot.sieve:/var/mail/localhost.localdomain/user1/.dovecot.sieve" + --volume "${TEST_TMP_CONFIG}/dovecot.sieve:/var/mail/localhost.localdomain/user1/home/.dovecot.sieve" ) _common_container_setup 'CONTAINER_ARGS_ENV_CUSTOM'