Repository navigation
feat(packaging): make maild's secrets key at first start (ADR-0047) - #129
Merged
Merged
Conversation
The .deb ships frostmail-secrets-key.service, a oneshot with ConditionPathExists=!/etc/credstore.encrypted/frostmail-secrets-key. It runs /usr/libexec/frostmail/make-secrets-key as root, which seals 32 random bytes with systemd-creds --with-key=auto, in a private directory beside the key, and publishes it with ln, so it never replaces a key. frostmail.service has Requires= and After= on it. The oneshot has no [Install] section: it is pulled, never upheld, so its condition is a clean skip. ADR-0047 amends ADR-0044 (core plan 0010, Phase 3 brief, point (b)). deb-check gains --line PATH LINE; make deb-check checks the unit, the helper, the condition and the ordering in the .deb. The staged-layout test checks the same, and systemd-analyze verify runs on the 3 units. A test runs the helper with a stub systemd-creds.
…a signal (cross-review) The pipe's status is systemd-creds', so a failed head could let it seal fewer than 32 bytes, and the condition would then skip every later run. A failed head now leaves a marker, and the helper exits 1 before it publishes. dash runs no EXIT trap when a signal ends it, so HUP, INT and TERM now exit 1 and the EXIT trap removes the private directory. Tests: a missing random source, and SIGTERM to the process group during the encrypt.
…eview) A reader that closed the FIFO at once could end the stub with SIGPIPE before the test's SIGTERM. The test now reads and checks the line, then signals.
Contributor
Author
|
Cross-review (openai/gpt-6.1-sol; coder anthropic claude-sonnet-5.5 with small edits by claude-opus-5.5): Ready at 1312fdd, Blocking: none, after 1 review and 2 re-reviews. Fixed findings: a failed head could publish a short key (now a marker, exit 1 before ln); dash skipped the EXIT trap on SIGTERM (now HUP/INT/TERM exit 1); the signal test's FIFO reader could cause SIGPIPE (now it reads the line first). CI green at this head. Next step after merge: Brian tags v0.1.1 (make bump). |
bketelsen
approved these changes
Oct 28, 2026
3 tasks done
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.
Core plan 0010, Phase 3 brief, point (b) (core#172), and Brian's answer B1 (T313b): frostmail's
.debmakes the secrets key on the host at first start. Snosi's sysextmaildwaits for this change inv0.1.1.What changes
frostmail-secrets-key.servicemakes it at first start. ADR-0044's status line says it is amended in part. ADR-0047's status is Accepted with Brian's decision of 2026-10-27; say so if you want it Proposed instead.packaging/lodge/frostmail-secrets-key.service(new) is a oneshot:ConditionPathExists=!/etc/credstore.encrypted/frostmail-secrets-key;Type=oneshot,RemainAfterExit=yes,After=tpm2.target;/etcwritable and the TPM visible (ProtectSystem=yes, noPrivateDevices=);[Install]section: nothing upholds or enables it, so its condition is a clean skip./usr/libexec/frostmail/make-secrets-key(new, frompackaging/lodge/make-secrets-key.sh) seals 32 random bytes withsystemd-creds encrypt --with-key=auto --name=frostmail-secrets-key, asseal-mail-secrets.sh --applydoes:ln, so it never replaces a key and a partial file never passes for one;frostmail.servicegetsRequires=frostmail-secrets-key.serviceandAfter=frostmail-secrets-key.service.stage.shstages the unit (0644) and the helper (0755). The.debgets them from the staged tree.The packaging tests
packaging/deb-check.py --line PATH LINEfails unless a regular file in the.debhas that exact line.make deb-check(run bymake deb, in CI's "Snapshot .deb" job and in the release) checks these things in the real.deb:Type=oneshot;Requires=andAfter=infrostmail.service.internal/lodge/package_test.gochecks the same rules on the staged tree:frostmail.socket,frostmail.service) must have noCondition*=, and the key unit has exactly its one condition;[Install],WantedBy=,RequiredBy=orUpheldBy=;Requires=andAfter=are parsed as lists;systemd-analyze verifyruns on all 3 units.internal/lodge/debcheck_test.gohas new bad packages that must fail: a missing line, a line on a missing file, and a partial line.internal/lodge/secretskey_test.goruns the helper with a stubsystemd-creds(the stub never sees or writes key bytes):Docs
specs/lodge-app.md,design/accounts.md, plan 0011,AGENTS.md, the docs index, and the hint inmove-mail-to-lodge.sh.Checks
make checkpasses under umask 022. Under umask 077,TestFileRefusesReadableFilefails on a cleanmaintoo.go test ./internal/lodge/ ./scripts/ -count=1passes.sh -npass onmake-secrets-key.shandstage.sh..deband runsdeb-check. No pnpm, node or cargo ran on the host.Next steps (Brian)
v0.1.1withmake bump. The release attestsfrostyard-maild_0.1.1_amd64.deb./usr/lib/systemd/system/frostmail-secrets-key.serviceand/usr/libexec/frostmail/make-secrets-keyin itsrequired-paths.txt.