fix(mailserver): Fix dovecot users file permissions after add-user

Ensure /etc/dovecot/users has 644 permissions and root:dovecot ownership
after adding a user. Without this, dovecot cannot read the passwd-file
and authentication fails with "Permission denied".

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2026-02-17 07:26:46 +01:00
parent 95e14c183b
commit 3aacabd5c1

View File

@ -384,6 +384,9 @@ cmd_add_user() {
if lxc_running; then
local pass_hash=$(lxc-attach -n "$CONTAINER" -- doveadm pw -s SHA512-CRYPT -p "$password")
echo "${email}:${pass_hash}:102:105::/var/mail/${domain}/${user}::" >> "$rootfs/etc/dovecot/users"
# Fix permissions (dovecot needs read access)
chmod 644 "$rootfs/etc/dovecot/users"
chown root:102 "$rootfs/etc/dovecot/users"
else
error "Container not running. Start it first."
return 1