Skip to content

Close the snapshot-signing follow-ups from #24 - #25

Merged
fastrevmd-lab merged 6 commits into
mainfrom
fix/signing-followups
Oct 26, 2026
Merged

fastrevmd-lab merged 6 commits into
mainfrom
fix/signing-followups

Conversation

@fastrevmd-lab

Copy link
Copy Markdown
Member

Summary

This closes the follow-ups parked in #24, the snapshot-signing PR, plus two more problems the final review of this branch found.

  • The installer could warn falsely, or miss a problem, when a drop-in changes ExecStart.
  • mecfeed-serve could hang on a FIFO in the snapshot directory.
  • Root wrote by name into directories that another account could control, in three places.
  • Key-command errors were thrown away.
  • The CI negative check passed on any failure.
  • There was no Docker key-rotation procedure.

Changes

  • Installer drop-in check. The missing-flag warning now reads the ExecStart systemd actually runs. That is the last ExecStart= in [Service] across the unit and <unit>.d/*.conf, with:

    • drop-ins in bytewise order
    • comment lines skipped
    • continuations joined with a space
    • spaces around = allowed

    Both units are checked on every install, not only when a customized unit is kept. /run, vendor, service.d/ and prefix drop-ins are not read; a shortcut: comment says so.

  • mecfeed-serve. current, snapshot.json and snapshot.sig open with O_NOFOLLOW | O_NONBLOCK, and then must be regular files, checked on the open fd. A FIFO no longer hangs a blocking thread, and the symlink check-then-open race is gone. libc was already in the lockfile and is now a direct dependency.

  • Installer root writes.

    • /etc/mecfeedmcp must not be group- or other-writable, and in a live install it must be root-owned. This is checked (shared with /etc/mecfeed-serve) before root writes feed.json.example or fixes audit-hmac.key.
    • tokens.json is now created by the service user, because root's install chmods by name inside the service-owned state dir.
  • Installer errors. It no longer discards stderr from --print-snapshot-signing-public-key, so a bad key shows its reason. The key id line now appears in normal output.

  • CI. The re-init check passes only if init fails with already exists and the key's hash is unchanged.

  • Docs. docs/operations.md gains "Rotation (Docker)". It recreates serve rather than restarting it, re-passes --listen and every --allow-cidr, and installs the new key as 65532 with mode 0600.

Verification

cargo fmt --all -- --check                                                    # ok
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings # ok
cargo test --workspace --locked        # all pass: serve 30 (+3 FIFO), core 44, mcp 50+4+4
cargo audit --deny warnings                                                   # clean
cargo deny check licenses bans sources                                        # ok
shellcheck -x packaging/lxc/install.sh packaging/tests/package-smoke.sh       # clean
scripts/verify-packaging.sh && scripts/build-package.sh                       # ok, incl. package smoke
  • New tests fail on the old code.

    • The 3 serve FIFO tests time out.
    • The drop-in smoke cases warn falsely or miss the problem.
    • With 2>/dev/null restored, the key-id assertion and the malformed-key assertion fail.
  • mawk. I ran the ExecStart parser under mawk (Debian's awk) on the disposable test LXC.

  • Live upgrade on the disposable test LXC, as real root:

    • the installer exited 0 and printed the key id
    • both services are active, and the feed returns 200
    • /etc/mecfeedmcp is root:mecfeedmcp 0750, tokens.json is mecfeedmcp 0600, and the .pub is root 0644
    • the tokens-creation command, run live as the service user, creates the file 0600, also under a private 0700 TMPDIR

    The live probe caught a bug in an earlier version that no staged test could. That version used runuser install /dev/stdin, and the service user cannot reopen a pipe root created.

Each commit had a task review and a Codex gate (codex exec review --commit), and the branch had a whole-branch review.

Checklist

  • cargo fmt --all -- --check passes
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings passes
  • cargo build --workspace --locked and cargo test --workspace --locked pass
  • Tests added or updated for this change, and they fail against the old code
  • cargo audit --deny warnings and cargo deny check licenses bans sources are clean
  • This touches mecfeed-serve snapshot serving. The reader now refuses non-regular files, including FIFOs and devices, and symlinks atomically. It fails closed with the same 503, and nothing on the publish side changes.
  • Fixtures are synthetic
  • No new telemetry, analytics, or outbound network call
  • Deterministic code decides; no model output is involved

Anything you're unsure about

  • The drop-in parser is a heuristic, and it only warns. For /run, vendor, service.d/ and prefix drop-ins, the upgrade path is systemctl show -P ExecStart.
  • The egress report has the same drop-in blind spot. install.sh reads only the base unit for IPAddressDeny, so a drop-in that clears it still reports ENFORCED. This predates this branch and is not fixed here, so it needs a follow-up.
  • A symlinked current logs the OS error. It now logs Too many levels of symbolic links instead of current is a symlink. This is cosmetic.
  • The serve FIFO tests call the three readers directly, not load. verify-packaging allows Command::new("mkfifo") only in *_test.rs, and unsafe is forbidden.

🤖 Generated with Claude Code

fastrevmd-lab and others added 6 commits October 25, 2026 18:39
The installer's missing-flag warning read only a preserved base unit, so
a drop-in that supplied the flag got a false "will not start" warning,
and a drop-in that overrode ExecStart without it went unnoticed, even on
a freshly installed unit. It now checks the last ExecStart across the
unit and its drop-ins, for both units on every install.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ow key-command errors

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The drop-in check took an ExecStart from any section, sorted drop-ins by
the caller's locale, and joined continued lines without the space
systemd inserts, so each could hide a missing flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tation

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@fastrevmd-lab
fastrevmd-lab merged commit c29c72f into main Oct 26, 2026
12 checks passed
@fastrevmd-lab
fastrevmd-lab deleted the fix/signing-followups branch October 26, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant