fix: [nomad-step-0] S0.3 — install vault + systemd auto-unseal + vault-init.sh (dev-persisted seal) (#823) #828
No reviewers
Labels
No labels
action
backlog
blocked
bug-report
cannot-reproduce
in-progress
in-triage
needs-triage
prediction/actioned
prediction/dismissed
prediction/unreviewed
priority
rejected
reproduced
tech-debt
underspecified
vision
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: disinto-admin/disinto#828
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/issue-823"
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?
Fixes #823
Changes
90f13c0313to57bc88b9a7AI Review
Summary
S0.3 is well-structured: the
lib-systemd.shextraction is clean, the install.sh extension is correct,systemd-vault.shis thorough with proper idempotency, and the bootstrap-order documentation is clear. One blocking bug preventsvault-init.shfrom working on its primary use case (first run), plus two minor findings.Findings
blocking
lib/init/nomad/vault-init.sh:106:vault_initialized()runsvault status | jq ...underset -euo pipefail.vault statusexits 2 when Vault is sealed/uninitialized — the exact first-run state this script must handle. Withpipefailactive, the pipeline exits 2,set -efires inside the$(vault_initialized)subshell, and the subshell exits 2. At line 150,initialized="$(vault_initialized)"is a standalone assignment — bash propagates the non-zero exit to the outer script, triggeringset -ethere too. The script exits before ever callingvault operator init. Comparevault_reachable()at lines 98–102, which explicitly uses|| status=$?to absorb exit 2 and even documents why:"|| status=$? avoids set -e tripping on the expected sealed-is-also-fine case".vault_initialized()has the identical problem without the fix. Minimal fix:initialized="$(vault_initialized)" || trueat line 150 — or add|| trueinside the function so it always exits 0.low
lib/init/nomad/lib-systemd.sh:43–54(systemd_install_unit): The extracted helper creates a temp file viamktempbut has notrapto clean it up ifinstall -m 0644 ...fails. The originalsystemd-nomad.sh(pre-refactor) had a propertrap 'rm -f "$tmp"' EXIT/trap - EXITguard around the same block. The temp file leaks to/tmpon failure. Low risk in practice (ephemeral directory), but regresses the original's cleanup discipline.low
lib/init/nomad/vault-init.sh:34,lib/init/nomad/systemd-vault.sh:26: Both referencedocs/VAULT.mdin the context of the HashiCorp Vault dev-persisted-seal tradeoff ("seal-key theft == vault theft, see docs/VAULT.md"). The actualdocs/VAULT.mddocuments the disinto vault dispatch / PR-approval workflow — a completely unrelated system. A developer following the link gets Forgejo branch protection docs, not seal model tradeoffs. The inline comments are self-contained and accurate; the reference just points to the wrong file. Either drop the reference or createdocs/HASHICORP-VAULT.md.Verdict
REQUEST_CHANGES — vault-init.sh will exit on first run: set -e fires when vault_initialized() pipeline exits 2 (sealed/uninitialized state) in standalone assignment context
Reviewed at
57bc88b| AGENTS.mdAI Review: REQUEST_CHANGES — vault-init.sh will exit on first run: set -e fires when vault_initialized() pipeline exits 2 (sealed/uninitialized state) in standalone assignment context
57bc88b9a7to24cb8f83a2AI Re-review (round 2)
Previous Findings
blocking
vault-init.sh:vault_initialized()pipeline exits 2 underset -e→ FIXED. Function now uses two-step capture:out="$(vault status ... || true)"then feeds tojqseparately, each guarded with|| true. Always exits 0. Comment updated to explain the fix clearly. Standalone assignment at line 163 is now safe.low
lib-systemd.sh:43–54: temp file leaked wheninstallfails → FIXED. Subshell +trap 'rm -f "$tmp"' EXITcorrectly cleans up on both success andset -e-induced abort. Consistent with the lessons-learned pattern for this codebase.low
systemd-vault.sh:26/vault-init.sh:34: staledocs/VAULT.mdreference → FIXED. Both files now use inline explanations of the dev-persisted-seal tradeoff. No external reference.New Issues
vault-init.sh:129–132:write_secret_filehas no trap aroundmktemp. Ifinstall -m 0400fails, the temp file holding the unseal key or root token leaks to/tmp.mktempon Linux defaults to 0600 root (script runs as root), so it's not world-readable — but cleanup discipline is inconsistent with the subshell+trap fix just applied tolib-systemd.sh. Non-blocking: same-user-only exposure and error paths are uncommon. Fine to track as follow-up.Verdict
APPROVE — All three previous findings addressed; one new low finding (write_secret_file temp cleanup) is not a blocker
Reviewed at
24cb8f8| Previous:57bc88b| AGENTS.mdAI Re-review (round 2): APPROVE — All three previous findings addressed; one new low finding (write_secret_file temp cleanup) is not a blocker