From bea29dd848b150b02c321e05eb2b0e6750a703d6 Mon Sep 17 00:00:00 2001 From: CyberMind-FR Date: Fri, 6 Feb 2026 06:28:07 +0100 Subject: [PATCH] fix(mailserver): Sync password changes to Dovecot users file - user_passwd now updates /etc/dovecot/users inside container - user_add also syncs new users to Dovecot - Fixes password reset not working (was only updating host file) Co-Authored-By: Claude Opus 4.5 --- .../files/usr/lib/mailserver/users.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/package/secubox/secubox-app-mailserver/files/usr/lib/mailserver/users.sh b/package/secubox/secubox-app-mailserver/files/usr/lib/mailserver/users.sh index 32abc353..25e995e0 100644 --- a/package/secubox/secubox-app-mailserver/files/usr/lib/mailserver/users.sh +++ b/package/secubox/secubox-app-mailserver/files/usr/lib/mailserver/users.sh @@ -51,6 +51,10 @@ user_add() { echo "$email:$hash" >> "${passfile}.tmp" mv "${passfile}.tmp" "$passfile" + # Sync to Dovecot inside container + local dovecot_entry="$email:$hash:1000:1000::/home/vmail/$domain/$user" + lxc-attach -n "$container" -- sh -c "grep -v '^$email:' /etc/dovecot/users > /tmp/users.tmp 2>/dev/null; echo '$dovecot_entry' >> /tmp/users.tmp; mv /tmp/users.tmp /etc/dovecot/users" + # Postmap lxc-attach -n "$container" -- postmap /etc/postfix/vmailbox 2>/dev/null @@ -119,8 +123,15 @@ user_passwd() { local hash=$(lxc-attach -n "$container" -- doveadm pw -s SHA512-CRYPT -p "$password" 2>/dev/null) [ -z "$hash" ] && hash=$(openssl passwd -6 "$password") + # Update host passfile sed -i "s|^$email:.*|$email:$hash|" "$passfile" + # Sync to Dovecot inside container + local user=$(echo "$email" | cut -d@ -f1) + local domain=$(echo "$email" | cut -d@ -f2) + local dovecot_entry="$email:$hash:1000:1000::/home/vmail/$domain/$user" + lxc-attach -n "$container" -- sh -c "grep -v '^$email:' /etc/dovecot/users > /tmp/users.tmp 2>/dev/null; echo '$dovecot_entry' >> /tmp/users.tmp; mv /tmp/users.tmp /etc/dovecot/users" + echo "Password changed for: $email" }