Repository navigation
feat: store disabled mailboxes in pcdb - #356
Merged
Merged
Conversation
Store the users with a disabled mailbox in a table of the Postfix configuration DB, instead of an environment variable: each row is one user, with an optional description. Postfix and Dovecot can read it at each lookup, so a change applies without a reload, and a bulk change is a single transaction. Assisted-by: Claude Code:claude-opus-5-5
Mail to a disabled mailbox was accepted, then refused by Dovecot and bounced to a possibly forged sender. Chain the LDAP user, group and alias maps with a SQL query that drops disabled and masked users from their results. Their addresses become unknown, like any address that is not assigned: Postfix rejects them, or delivers them to the catch-all. A group skips its disabled members, and is unknown if none is left. Copies that still reach a disabled mailbox through SQL aliases are discarded, and its forwards ignored. The masked users are the system accounts of the user domain, like krbtgt. They replace DOVECOT_DISABLED_USERS in discovery.env, and only names that need no escaping are accepted. Assisted-by: Claude Code:claude-opus-5-5
Mount the Postfix configuration DB read-only, and deny the login of users with a disabled mailbox with a SQL passdb, before the LDAP one. Their mailbox is kept and still listed by the userdb. Only the masked users stay out of the LDAP filters. Assisted-by: Claude Code:claude-opus-5-5
Actions read and write the disabled_mailboxes table, and no longer reload Postfix and Dovecot. set-mailbox-enabled accepts an optional description, and list-user-mailboxes returns it. import-module describes the mailboxes it disables. An update moves DOVECOT_DISABLED_USERS to the table before the containers restart, then removes the variable. Assisted-by: Claude Code:claude-opus-5-5
Add the disabled mailbox SMTP suite and its keywords. A group whose members are all disabled is unknown, or goes to the catch-all. Check the description of a disabled mailbox in the API. Assisted-by: Claude Code:claude-opus-5-5
DavidePrincipi
force-pushed
the
bug-8185
branch
from
November 25, 2026 08:26
f5d338b to
838e2c0
Compare
DavidePrincipi
marked this pull request as ready for review
November 25, 2026 10:50
stephdl
reviewed
Nov 25, 2026
Dovecot keeps its SQLite connection to pcdb open. When restore-module replaced the file after the services had started, Dovecot kept reading the removed one: restored disabled mailboxes could log in until its next reload. They could also log in while the services ran on the empty DB, before the restored one was loaded. Create pcdb in a separate pcdb-init container, started by a unit that Postfix and Dovecot require. If pcdb.sqlite is missing, it loads the restored backup dump, or creates the initial DB; the services then start with the final DB, and restore-module no longer replaces it. A failed load leaves no DB, so the services do not start on a wrong one. Assisted-by: Claude Code:claude-opus-5-5
stephdl
approved these changes
Nov 26, 2026
stephdl
left a comment
Contributor
There was a problem hiding this comment.
I tested this branch on a node with an AD user domain. A disabled user with a mixed case name is rejected with "User unknown in virtual alias table", in both cases of the address, like an address that does not exist. Enabled users are still accepted, and copies to the disabled mailbox go to discard:. The change applies at once, without a reload.
All my points from #348 are addressed: no LDAP filter escaping in Dovecot anymore, the restore loads the pcdb dump before Postfix and Dovecot start, and the tests wait for the log lines instead of a fixed sleep.
This was referenced Nov 26, 2026
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.
Some installations disable many mailboxes, even in bulk, but the list was a single environment variable: each change rewrote it and reloaded Postfix and Dovecot. Mail to disabled mailboxes and group members was also bounced to possibly forged senders (NethServer/dev#8185, NethServer/dev#8205). Part of Mail 2.0 (NethServer/dev#8267).
Disabled mailboxes move to a table of the Postfix database, with an optional description. Postfix and Dovecot read it at each lookup: changes apply at once, with no reload and no escaping. Their addresses are now unknown (rejected, or sent to the catch-all), groups skip them, remaining copies are dropped without a bounce, and login is denied. Mailbox contents are kept, Dovecot still lists them (e.g. for
doveadm -Ajobs), and master users can still log in.pcdb-initunit creates the database before Postfix and Dovecot start; after a restore it loads the backup dump, so the services never run on an empty or replaced database.DOVECOT_DISABLED_USERSvariable is migrated on update.How to test
See also
Generated by Claude Code:claude-opus-5-5 with nethserver-pr