mirror of
https://github.com/tomav/docker-mailserver
synced 2025-08-31 06:15:28 +00:00
feat: Allow changing the Dovecot vmail UID/GID via ENV (#3550)
Some deployment scenarios are not compatible with `5000:5000` static vmail user with `/var/mail`. This feature allows adjusting the defaults to a UID / GID that is compatible. Signed-off-by: vincent <vincent@ducamps.win> Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
This commit is contained in:
@@ -70,7 +70,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}/home::${USER_ATTRIBUTES}"
|
||||
DOVECOT_USERDB_LINE="${LOGIN}:${PASS}:${DMS_VMAIL_UID}:${DMS_VMAIL_GID}::/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"
|
||||
else
|
||||
@@ -141,7 +141,7 @@ function _create_dovecot_alias_dummy_accounts() {
|
||||
fi
|
||||
fi
|
||||
|
||||
DOVECOT_USERDB_LINE="${ALIAS}:${REAL_ACC[1]}:5000:5000::/var/mail/${REAL_DOMAINNAME}/${REAL_USERNAME}::${REAL_ACC[2]:-}"
|
||||
DOVECOT_USERDB_LINE="${ALIAS}:${REAL_ACC[1]}:${DMS_VMAIL_UID}:${DMS_VMAIL_GID}::/var/mail/${REAL_DOMAINNAME}/${REAL_USERNAME}::${REAL_ACC[2]:-}"
|
||||
if grep -qi "^${ALIAS}:" "${DOVECOT_USERDB_FILE}"; then
|
||||
_log 'warn' "Alias '${ALIAS}' will not be added to '${DOVECOT_USERDB_FILE}' twice"
|
||||
else
|
||||
|
@@ -39,9 +39,9 @@ function _get_dms_env_value() {
|
||||
# /var/mail folders (used during startup and change detection handling).
|
||||
function _chown_var_mail_if_necessary() {
|
||||
# fix permissions, but skip this if 3 levels deep the user id is already set
|
||||
if find /var/mail -maxdepth 3 -a \( \! -user 5000 -o \! -group 5000 \) | read -r; then
|
||||
if find /var/mail -maxdepth 3 -a \( \! -user "${DMS_VMAIL_UID}" -o \! -group "${DMS_VMAIL_GID}" \) | read -r; then
|
||||
_log 'trace' 'Fixing /var/mail permissions'
|
||||
chown -R 5000:5000 /var/mail || return 1
|
||||
chown -R "${DMS_VMAIL_UID}:${DMS_VMAIL_GID}" /var/mail || return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user