From b3074b303e3eb1421b2c28fe81e5e129ede408c9 Mon Sep 17 00:00:00 2001 From: sysops Date: Fri, 20 Mar 2026 01:47:48 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20LDAP=20leere=20BindPassword=20schl=C3=A4?= =?UTF-8?q?gt=20Login=20fehl=20+=20install.sh=20Passwort-Extraktion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - auth.Manager.Login: LDAP-Fallback überspringen wenn URL oder BindPassword leer (verhindert go-ldap ErrorEmptyPassword Code 206 bei fehlerhaftem LDAP-Config-Eintrag) - install.sh: grep-Muster von variablenbreitem Lookbehind auf \K umgestellt (PCRE unterstützt keine variablen Lookbehinds — Passwörter wurden nie korrekt extrahiert) - install.sh: Wartezeit auf Backend-Start erhöht (bis zu 15s statt 2s) Co-Authored-By: Claude Sonnet 4.6 --- install.sh | 13 +++++++++---- internal/auth/auth.go | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 699b4e5..49cd32e 100755 --- a/install.sh +++ b/install.sh @@ -325,10 +325,15 @@ if [ -f "$INSTALL_DIR/update.sh" ]; then info "Führe erstes Deployment durch (Build + Start)..." bash "$INSTALL_DIR/update.sh" # Echte Passwörter aus Journal lesen (Backend gibt sie beim ersten Start aus) - sleep 2 - PW_SUPERADMIN=$(journalctl -u archivmail --no-pager -n 50 | grep -oP '(?<=superadmin\s+: )\S+' | tail -1) - PW_ADMIN=$(journalctl -u archivmail --no-pager -n 50 | grep -oP '(?<=admin\s+: )\S+' | tail -1) - PW_AUDITOR=$(journalctl -u archivmail --no-pager -n 50 | grep -oP '(?<=auditor\s+: )\S+' | tail -1) + # Auf Backend warten (bis zu 15 Sekunden) + for _i in $(seq 1 15); do + _pw=$(journalctl -u archivmail --no-pager -n 100 | grep 'admin' | grep -oP ':\s+\K[0-9a-f]{16,}' | tail -1) + [[ -n "$_pw" ]] && break + sleep 1 + done + PW_SUPERADMIN=$(journalctl -u archivmail --no-pager -n 100 | grep 'superadmin' | grep -oP ':\s+\K\S+' | tail -1) + PW_ADMIN=$(journalctl -u archivmail --no-pager -n 100 | grep ' admin ' | grep -v superadmin | grep -oP ':\s+\K\S+' | tail -1) + PW_AUDITOR=$(journalctl -u archivmail --no-pager -n 100 | grep 'auditor' | grep -oP ':\s+\K\S+' | tail -1) [[ -n "$PW_ADMIN" ]] || PW_ADMIN="(nicht gefunden — siehe: journalctl -u archivmail | grep admin)" [[ -n "$PW_AUDITOR" ]] || PW_AUDITOR="(nicht gefunden — siehe: journalctl -u archivmail | grep auditor)" [[ -n "$PW_SUPERADMIN" ]] || PW_SUPERADMIN="(nicht gefunden — siehe: journalctl -u archivmail | grep superadmin)" diff --git a/internal/auth/auth.go b/internal/auth/auth.go index a7f9d1b..96a9eb3 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -91,7 +91,7 @@ func (m *Manager) Login(username, password string) (token string, user *userstor tenantID, lookupErr := m.tenantLookup.GetTenantIDByDomain(ctx, domain) if lookupErr == nil && tenantID != nil { tcfg, tErr := m.tenantLdapStore.GetWithPassword(ctx, *tenantID) - if tErr == nil && tcfg != nil && tcfg.Enabled { + if tErr == nil && tcfg != nil && tcfg.Enabled && tcfg.URL != "" && tcfg.BindPassword != "" { attrs, authErr := ldapauth.Authenticate(ldapauth.Config{ URL: tcfg.URL, BindDN: tcfg.BindDN, @@ -137,7 +137,7 @@ func (m *Manager) Login(username, password string) (token string, user *userstor // 3. Global LDAP fallback — only reached if no matching tenant LDAP config found. if m.ldapStore != nil { cfg, ldapErr := m.ldapStore.GetWithPassword(context.Background()) - if ldapErr == nil && cfg != nil && cfg.Enabled { + if ldapErr == nil && cfg != nil && cfg.Enabled && cfg.URL != "" && cfg.BindPassword != "" { attrs, authErr := ldapauth.Authenticate(ldapauth.Config{ URL: cfg.URL, BindDN: cfg.BindDN,