Skip to content

mkbundle/mkimage refuse a stale rootfs tarball unless explicitly overridden - #915

Merged
VijitSingh97 merged 2 commits into
develop-v2from
fix/896-stale-tarball-guard
Aug 13, 2026
Merged

mkbundle/mkimage refuse a stale rootfs tarball unless explicitly overridden#915
VijitSingh97 merged 2 commits into
develop-v2from
fix/896-stale-tarball-guard

Conversation

@VijitSingh97

Copy link
Copy Markdown
Collaborator

Closes #896.

A present-but-stale os/build/pithead-root.tar looked identical to a fresh one — a bench deploy bundled the previous session's tarball, RAUC installed it, everything came up green, and only the manual BUILD_COMMIT check caught that the fix under test never shipped. The information was already inside the artifact.

  • verify_tarball_commit() in populate-slot.sh (the file both consumers already share): one tar -xO of opt/pithead/BUILD_COMMIT, compared against the working tree with build-image.sh's exact -dirty suffix. Match proceeds; mismatch refuses naming both commits; PITHEAD_STALE_TARBALL_OK=1 is the explicit escape — the same fail-closed shape as the existing version/variant/signing guards.
  • Called from both mkbundle.sh and mkimage.sh right after their existence guards.
  • Review amendment: these scripts normally run under sudo, and root's git refuses a user-owned checkout (dubious ownership; -c safe.directory is documented as ignored from the command line) — the guard falls back to reading the commit as SUDO_USER, and an unreadable tree refuses with a message naming the real cause instead of blaming staleness.

Tier-1 coverage with fabricated fixture tarballs: fresh accepted, stale refused (message names both commits + the override), missing stamp refused, unreadable tree refused fail-closed, override works on both refusal classes. Stack suite: 2182 passed, 0 failed.

Ponytail review: two refusal paths each keep their own override block — merging would save ~6 lines but collapse two different diagnoses into one message. Lean otherwise.

🤖 Generated with Claude Code

VijitSingh97 and others added 2 commits August 13, 2026 07:28
mkbundle.sh and mkimage.sh only checked that os/build/pithead-root.tar
existed, not that it matched the working tree. A leftover tarball from
a previous build session looks identical to a fresh one, gets bundled
and installed, and every downstream check comes up green while the old
code is actually running — only a manual BUILD_COMMIT read on the box
caught it once.

Add verify_tarball_commit to the shared populate-slot.sh: extract the
tarball's own opt/pithead/BUILD_COMMIT stamp and compare it to git
rev-parse HEAD (dirty-suffixed the same way build-image.sh stamps it).
Match proceeds; mismatch refuses by default, naming both commits, with
PITHEAD_STALE_TARBALL_OK=1 as the explicit override — the same
fail-closed shape the existing version/variant/signing guards use.
Both mkbundle.sh and mkimage.sh call it right after their existing
existence guard.

Covered at tier 1 in tests/stack/run.sh with a fabricated fixture
tarball (no image build needed): fresh match, foreign-commit refusal,
the override, and a tarball with no stamp at all.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Root's git refuses another user's checkout (dubious ownership), and
mkbundle/mkimage normally run under sudo — the guard would have refused
every sudo build on a user-owned tree, the exact flow it exists to
protect. Fall back to reading the commit as SUDO_USER; if the tree
still cannot be read, refuse with a message that names the real cause
instead of blaming staleness (fail closed, same explicit escape).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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