Fix #7150: passwd-verify.lua wipes auth cache during any nginx outage#7290
Open
wryfi wants to merge 1 commit into
Open
Fix #7150: passwd-verify.lua wipes auth cache during any nginx outage#7290wryfi wants to merge 1 commit into
wryfi wants to merge 1 commit into
Conversation
… any nginx restart or unavailability) - distinguishes between text and numeric responses from nginx - prevents auth cache from being invalidated due to nginx unavailability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contribution Guidelines
What does this PR include?
Short Description
Fixes #7150.
passwd-verify.luawiped the Dovecot auth cache for affected users whenevera host reboot, a full-stack snapshot/backup, or any transient Docker network blip.
On a network-level failure,
https.requestreturnsnilplus an error string(e.g.
"host or service not provided, or not known"), socis not a numeric HTTPstatus code. The existing
if c ~= 200 and c ~= 401check treated this identicallyto a credential rejection and returned
PASSDB_RESULT_PASSWORD_MISMATCH, which clearsthe cache entry — causing hard auth failures for reconnecting clients (iOS Mail in
particular, which has no Keychain fallback).
This PR adds a guard ahead of the HTTP-status check: when
cis not a number, therequest failed at the network level, so it returns
PASSDB_RESULT_INTERNAL_FAILURE("Upstream unreachable"), which keeps the existing cache entry instead of wiping
it. Genuine HTTP responses (200/401, and 4xx/5xx errors) are handled exactly as before.
The log concatenation is also hardened to
tostring(c)so it can't error on anon-string/nil value.
This restores the pre-2025-05 behavior where a brief nginx interruption was benign for
already-authenticated clients.
Affected Containers
Did you run tests?
Yes — tested on a live mailcow instance by overriding
passwd-verify.luaand exercisingthe real-world scenario that originally surfaced the bug.
What did you tested?
The Dovecot auth path (
dovecot-mailcow) through a full-stack restart, using my backupprocedure as the trigger: stop the entire stack, snapshot the volumes, then start the
stack again. This is exactly the kind of operation that leaves
nginx:9082unreachablewhile Dovecot auth workers are still serving reconnecting IMAP clients.
I first noticed the failure on the stock file, then applied the patched
passwd-verify.luaas an override and repeated the same backup/restart cycle with activeIMAP clients connected.
What were the final results? (Awaited, got)
auth cache entries for connected users were wiped and clients hit hard authentication
failures during the nginx-unavailable window.
unaffected. got: as awaited — no cache wipe, and connected IMAP clients stayed
authenticated across the entire stop/snapshot/restart cycle, with no re-auth prompts.
luac -p data/conf/dovecot/auth/passwd-verify.lua→ awaited: no syntax errors.got: syntax OK.