2
0
mirror of https://github.com/tomav/docker-mailserver synced 2025-08-31 14:25:59 +00:00

chore: Extract out /var/mail ownership workaround (#2628)

Keep it in sync between the two locations via shared helper method.
This commit is contained in:
Brennan Kinney
2022-06-08 10:09:19 +12:00
committed by GitHub
parent 4b37cb5383
commit 0a722276a8
3 changed files with 21 additions and 12 deletions

View File

@@ -20,3 +20,19 @@ function _get_dms_env_value
VALUE=$(grep "^${1}=" /etc/dms-settings | cut -d '=' -f 2)
printf '%s' "${VALUE:1:-1}"
}
# TODO: `chown -R 5000:5000 /var/mail` has existed since the projects first commit.
# It later received a depth guard to apply the fix only when it's relevant for a dir.
# Assess if this still appropriate, it appears to be problematic for some LDAP users.
#
# `helpers/accounts.sh:_create_accounts` (mkdir, cp) appears to be the only writer to
# /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
_log 'trace' 'Fixing /var/mail permissions'
chown -R 5000:5000 /var/mail || return 1
fi
}