feat(mail): offer GSSAPI on dovecot IMAP #296
No reviewers
Labels
No labels
bug
enhancement
in-progress
needs-info
needs-triage
p0
ready-for-agent
ready-for-human
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/nixos!296
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "afk/291"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #291
Enables the GSSAPI mechanism on
mail's Dovecot so Thunderbird onnbcan authenticate to IMAP with the desktop-login TGT. Follow-up to #290/#293, which builtdovecot_2_3with--with-gssapi=yes— that overlay is a hard prerequisite, since an unsupported mechanism inauth_mechanismsisi_fatalat auth-process start (src/auth/mech.c:162).One file, three settings:
Before you merge — please read
1. This is not dry-built. The AFK sandbox has no Nix, so
scripts/pre-commitcould not run (ERROR: 'nix-instantiate' command not found) and the commit used--no-verify. Everything below was established by reading the actual nixpkgsnixos-26.05module and dovecot 2.3.21.1 source, not by evaluating. Please let the hook run before merging.2. SMTP and ManageSieve will start advertising GSSAPI too, and it will fail there.
auth_mechanismsis global in Dovecot 2.3 — there is one mechanism register (src/auth/main.c:198-202) shared by every service, and it cannot be scoped per protocol. Postfix uses this same auth process (postfix.nix:236-241,smtpd_sasl_type = dovecotoverprivate/auth), andsmtpd_sasl_mechanism_filteris unset — its default!external, static:restlets GSSAPI through. So 25/465/587 will announceAUTH PLAIN LOGIN GSSAPI.Worse than a plain rejection: Dovecot builds the acceptor as
<lowercased service>/<gssapi_hostname>(mech-gssapi.c:157-168), so submission asks forsmtp/imap.cloonar.com, which does not exist;gss_acquire_credfails and the request ends inauth_request_internal_failure→ Postfix454 4.7.0, a temporary failure that clients retry rather than falling back. ManageSieve on 4190 has the same problem withsieve/imap.cloonar.com. Only clients that actually select GSSAPI are affected — password clients are untouched — but that includes anything auto-negotiating the strongest mechanism.The issue puts "any Postfix change" out of scope, so I did not make it. The one-line containment, which preserves exactly today's banner, is:
Your call whether that belongs in this PR, a follow-up, or nowhere.
Deviations from the issue text, and why
plain login gssapi, notplain gssapi. nixpkgs 26.05 declaresauth_mechanismsas an option with default[ "plain" "login" ](nixos/modules/services/mail/dovecot.nix:442-453), somailalready advertisesAUTH=LOGINtoday. Writingplain gssapiwould have silently withdrawn LOGIN from every client on the host. The diff strictly appends to what is served now.Set in
services.dovecot2.settings, notdovecotExtraConfig. ThedoveConfgenerator emits!includelines before the rendered settings block (dovecot.nix:170-178), and last-wins for dovecot globals. Anauth_mechanismsin the include would have been overridden by the module's own default — and silently, with GSSAPI simply never offered. This is the same ordering trap the existingmail_pluginscomment describes. (Type note: the option isoneOf [ (attrsOf bool) (listOf str) ], so the list form is mandatory; a bare"plain gssapi"string fails to evaluate.)auth_gssapi_hostnameadded — not in the issue, but required for the stated SPN. Its default is empty, which resolves to the local hostname, so the acceptor would have beenimap/mail, notimap/imap.cloonar.com. Verified thatimap.cloonar.comis a real A/AAAA record and not a CNAME ontomail.cloonar.com, so krb5 forward canonicalisation is a no-op on both ends and the SPN stays put. If anyone ever converts it to a CNAME, this silently breaks.Keytab is
root:root, notdovecot. There is nodovecotuser on this host — the module createsdovecot2anddovenull, and this config'sservice auth { user = root }(in the include) means the auth process that reads the keytab runs as root.chown dovecotas written in the issue would have failed outright.auth_username_formatdeliberately not set. Checked as the issue asked: dovecot 2.3.21.1's default is already%Lu(src/auth/auth-settings.c:297), and it is applied to the GSSAPI display name viaauth_request_fix_username.dominik.polakovics@CLOONAR.COM→dominik.polakovics@cloonar.com, exactly themailattributeuser_filterkeys on. The mapping is free; setting it would be a no-op.Corrected the
ktaddwarning. The issue's "a second run rotates the key and silently invalidates the keytab" is true for ADR-0022's Keycloak case, where the keytab is base64'd into sops and a re-run invalidates the committed copy. Herektadd -kwrites to the only copy and appends the new kvno, so the file stays valid. I left the claim out of the module rather than repeat it.Human steps
On
mail(it is the KDC, so nothing goes in sops)./var/lib/dovecotalready exists —rspamd.nix's preStart creates it — soktadd -kwill not fail on a missing directory:Merging before this is safe: Dovecot registers the keytab lazily on the first GSSAPI attempt and never stats it at startup (
mech-gssapi.c:106-119, called only fromobtain_service_credentialsbehind a one-shot guard at:145-148). The daemon starts, PLAIN and LOGIN keep working, and only GSSAPI logins fail./var/lib/dovecotis not inborgbackup.nix's excludes, so the keytab is backed up.On
nb, in thecloonarorworkprofile only — left as a human step per the issue's scope. Worth knowing before you do it by hand: home-managerrelease-25.11's thunderbird module does not emitauthMethodfor a non-Gmail account, so a change made in the Thunderbird UI will persist and will not be reverted byhome-manager switch. If you would rather have it declarative, it is one line in thedominik.polakovics@cloonar.comaccount block ofhosts/nb/users/dominik.nix— that account is already scoped to[ "cloonar" "work" ]and never appears inprivate:Note that this would cover both secondary profiles, not one, and that it locks the pref —
user.jsis re-applied on every Thunderbird start, so later UI changes to it in those two profiles would be reverted.Verification
scripts/pre-commitdry-buildsmail(not run here — no Nix in the sandbox)systemctl status dovecot2clean after deployopenssl s_client -starttls smtp -connect mail.cloonar.com:587— check whether theAUTHline now lists GSSAPI, and that a submission client on each tenant still sends (see risk 2 above)klistshows a service ticket forimap/imap.cloonar.com@CLOONAR.COMRollback is reverting the commit; the principal and keytab can stay or go with
delprinc.No ADR: ADR-0022 already records this decision ("they need a keytab and one more entry in
auth_mechanisms"), and this is its mechanical follow-through, not a new trade-off.