fix(mailserver): Use uid/gid 5000 for vmail user in Dovecot config

Fixes Roundcube IMAP "Internal error occurred" caused by Dovecot
running mail processes as uid 102 (Alpine default) instead of the
actual vmail user uid 5000.

Changes:
- configure_postfix: virtual_uid_maps/gid_maps 102/105 → 5000/5000
- configure_dovecot: mail_uid/gid, first_valid_uid, userdb args
- cmd_add_user: passwd file entries and ownership

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2026-02-25 07:11:43 +01:00
parent 5fd3ebb17a
commit d43855b3d1
2 changed files with 18 additions and 9 deletions

View File

@ -3489,3 +3489,12 @@ git checkout HEAD -- index.html
- **Fix Applied:** - **Fix Applied:**
- `p2p-mesh.sh`: Silenced usage output when sourced as library - `p2p-mesh.sh`: Silenced usage output when sourced as library
- **Tested:** All RPCD methods working via ubus, discovery mode toggle, bulk tokens - **Tested:** All RPCD methods working via ubus, discovery mode toggle, bulk tokens
27. **Mailserver Dovecot UID/GID Fix (2026-02-25)**
- Fixed Roundcube IMAP "Internal error" caused by Dovecot running as wrong user (uid 102 instead of 5000)
- **Problem:** Dovecot config had hardcoded uid=102/gid=105 from Alpine defaults, but vmail user is uid=5000/gid=5000
- **Files Modified:**
- `mailserverctl`: Fixed 7 uid/gid references (102→5000, 105→5000)
- `dovecot.conf` template: Changed mail_uid/gid, first_valid_uid/last_valid_uid
- `configure_postfix`: Changed virtual_uid_maps/virtual_gid_maps
- `cmd_add_user`: Changed passwd file uid:gid entries

View File

@ -203,8 +203,8 @@ mynetworks = 127.0.0.0/8 [::1]/128 192.168.255.0/24
virtual_mailbox_domains = $domain virtual_mailbox_domains = $domain
virtual_mailbox_base = /var/mail virtual_mailbox_base = /var/mail
virtual_mailbox_maps = lmdb:/etc/postfix/vmailbox virtual_mailbox_maps = lmdb:/etc/postfix/vmailbox
virtual_uid_maps = static:102 virtual_uid_maps = static:5000
virtual_gid_maps = static:105 virtual_gid_maps = static:5000
virtual_transport = lmtp:unix:private/dovecot-lmtp virtual_transport = lmtp:unix:private/dovecot-lmtp
# SASL auth via Dovecot # SASL auth via Dovecot
@ -282,10 +282,10 @@ configure_dovecot() {
protocols = imap lmtp protocols = imap lmtp
listen = * listen = *
mail_location = maildir:/var/mail/%d/%n mail_location = maildir:/var/mail/%d/%n
mail_uid = 102 mail_uid = 5000
mail_gid = 105 mail_gid = 5000
first_valid_uid = 102 first_valid_uid = 500
last_valid_uid = 102 last_valid_uid = 65534
# Auth # Auth
auth_mechanisms = plain login auth_mechanisms = plain login
@ -295,7 +295,7 @@ passdb {
} }
userdb { userdb {
driver = static driver = static
args = uid=102 gid=105 home=/var/mail/%d/%n args = uid=5000 gid=5000 home=/var/mail/%d/%n
} }
# SSL # SSL
@ -383,10 +383,10 @@ cmd_add_user() {
# Generate password hash and add to users file # Generate password hash and add to users file
if lxc_running; then if lxc_running; then
local pass_hash=$(lxc-attach -n "$CONTAINER" -- doveadm pw -s SHA512-CRYPT -p "$password") 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" echo "${email}:${pass_hash}:5000:5000::/var/mail/${domain}/${user}::" >> "$rootfs/etc/dovecot/users"
# Fix permissions (dovecot needs read access) # Fix permissions (dovecot needs read access)
chmod 644 "$rootfs/etc/dovecot/users" chmod 644 "$rootfs/etc/dovecot/users"
chown root:102 "$rootfs/etc/dovecot/users" chown root:5000 "$rootfs/etc/dovecot/users"
else else
error "Container not running. Start it first." error "Container not running. Start it first."
return 1 return 1