Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions os/mini/release-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,57 @@ identity_launcher_path() {
else printf '%s\n' "${PAYLOAD_DIR:-/opt/1bit-package}/1bit/1bit"; fi
}

# Does the identity describe the payload the image actually carries? engine#1557: `payload=` is a DECLARED value
# (PAYLOAD_NAME from the build's environment, container-build.sh:352) and nothing compared it with the bytes, so c32
# and c33 both shipped `payload=lemonade-onebit-rc-2026-11-05-c26c` beside later payloads.
#
# A name cannot be checked from inside the image — the image has no copy of its own tarball, which is why the first
# version of this row (matching a stem in /data/SHA256SUMS) was wrong: nothing in this repo writes a payload tarball
# there, and the only .tar.zst a data partition holds is the PROOF bundle. So the check is on CONTENT instead: the
# build writes `payload_manifest=<sha256 of the sorted relative file paths of /payload>` beside the name
# (container-build.sh, "engine#1557"), and this row recomputes the same expression over the payload present. A
# different payload has a different path list, which is the lie that survived two cycles; the name stays in the row's
# message as the human-readable claim it is.
#
# The image-side walk is metadata only and the payload-modes row below already walks the same tree, so this adds no
# order of cost. SKIP, never a pass, when the identity has no manifest (the mini schema) or the payload is not where
# an appliance keeps it: a row that cannot see the bytes must not call the claim true.
payload_verdict() { # <claimed name> <claimed manifest|""> <manifest of the payload present|"">
_pc=${1:-} _pm=${2:-} _pa=${3:-}
if [ -z "$_pa" ]; then printf 'SKIP the payload is not at the appliance path, so the identity cannot be compared with it'; return 0; fi
case "$_pm" in
'') printf 'SKIP this image states no payload_manifest (the mini schema), so payload=%s is still only a declaration' "${_pc:-unknown}" ;;
*[!0-9a-f]*) printf 'FAIL the identity payload_manifest is not a hex digest (%s) - malformed, not merely old' "$_pm" ;;
*) if [ "$_pm" = "$_pa" ]; then printf 'PASS payload=%s, manifest matches the payload the image carries' "${_pc:-unknown}"
else printf 'FAIL the identity describes a different payload (manifest %s) than the one present (%s) - the c32/c33 shape' "$_pm" "$_pa"; fi ;;
esac
}

# Which file's bytes does an `engine_sha256` claim have to match? Two schemas, two layouts (engine#1481/#1541):
# * v3 (`container-build.sh`): the payload launcher at /opt/1bit-package/1bit/1bit;
# * mini (`os/mini/mkimage.sh`): the engine the image RUNS, /bin/1bit - a symlink to the image's own copy. Inside the
# booted image that symlink resolves to the image copy, which is why reading it here is right; on the build host the
# same expression escapes to the build tree, so the WRITER hashes $root$bin instead of hashing the symlink.
# An empty first argument means "no checkable claim"; then the git short sha (if any) decides whether the row SKIPs.
# Pure, so --self-test drives it: <claimed engine_sha256|""> <git sha|"">
identity_launcher_path() {
[ -n "${1:-}" ] || return 0
if [ -n "${2:-}" ]; then printf '%s\n' "${MINI_LAUNCHER:-/bin/1bit}"
else printf '%s\n' "${PAYLOAD_DIR:-/opt/1bit-package}/1bit/1bit"; fi
}

# Does the identity's `payload=` name a payload the image actually carries? engine#1557: it was a DECLARED value
# (PAYLOAD_NAME from the build's environment, container-build.sh:352) and nothing compared it, so c32 and c33 both
# shipped `payload=lemonade-onebit-rc-2026-11-05-c26c` beside later payloads.
#
# The authority is the data partition's own checksum table: /data/SHA256SUMS lists the payload tarball(s) the image
# was built with, so `<stem>.tar.zst` present there is a fact about the image, not about the build's environment.
# Deliberately NOT the payload directory's name: the tree is always /opt/1bit-package, so comparing against it
# would pass for any claim at all - the vacuous check the issue warns about.
#
# SKIP, never a pass, when the image carries no payload tarball in its table (an image-only cut, or a stick whose
# data partition was written by an older layout): a row that cannot see the bytes must not call the claim true.

identity_verdict() {
_ce=${1:-} _ae=${2:-} _ch=${3:-} _ah=${4:-}
case "$_ce" in ''|*[!0-9a-f]*) printf 'FAIL the identity file'"'"'s engine_sha256 is not a hex digest (%s) - malformed, not merely old' "${_ce:-empty}"; return 0 ;; esac
Expand Down Expand Up @@ -759,6 +810,12 @@ if [ "${1:-}" = --self-test ]; then
check PASS "$(identity_verdict aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb)"
check FAIL "$(identity_verdict aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7ba2110811111111111111111111111111111111111111111111111111111111 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb)" # the c26-in-a-c32-image shape: engine claim vs shipped launcher
check FAIL "$(identity_verdict aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc)" # libhsa claim vs the runtime the image carries
# engine#1557: the identity's payload manifest against the payload present
check PASS "$(payload_verdict lemonade-onebit-rc-2026-11-08-c33 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)"
check FAIL "$(payload_verdict lemonade-onebit-rc-2026-11-05-c26c cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)" # the c32/c33 shape: an identity describing another payload
check FAIL "$(payload_verdict lemonade-onebit-rc-2026-11-08-c33 not-a-digest aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)" # malformed claim
check SKIP "$(payload_verdict lemonade-onebit-rc-2026-11-08-c33 '' aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)" # mini schema: no manifest to compare
check SKIP "$(payload_verdict lemonade-onebit-rc-2026-11-08-c33 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa '')" # payload not at the appliance path
check FAIL "$(identity_verdict 89a6c386 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb)" # malformed claim is FAIL, not unknown
check FAIL "$(identity_verdict aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa '' bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb)" # nothing to check the claim against
check PASS "$(identity_verdict aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa none '')" # `none` and nothing on the loader path: consistent
Expand Down Expand Up @@ -1868,6 +1925,28 @@ if [ -f "$ID" ]; then
*) fail identity "${_idv#FAIL } (${_idinfo})" ;;
esac
fi
# engine#1557: payload= and its manifest against the payload the image actually carries
_pv_claim=$(sed -n 's/^payload_manifest *[=:] *//p' "$ID" 2>/dev/null | head -1 | tr -d '[:space:]')
_pv_actual=
_pv_dir=${PAYLOAD_DIR:-/opt/1bit-package}
if [ -d "$_pv_dir" ]; then
_pv_actual=$(find "$_pv_dir" -type f 2>/dev/null | sed "s|^$_pv_dir/||" | LC_ALL=C sort | sha256sum | cut -d' ' -f1)
fi
_pvv=$(payload_verdict "${_id_name:-}" "$_pv_claim" "$_pv_actual")
case "$_pvv" in
PASS*) pass identity-payload "${_pvv#PASS }" ;;
SKIP*) skip identity-payload "${_pvv#SKIP }" ;;
*) fail identity-payload "${_pvv#FAIL }" ;;
esac
if [ -f /data/SHA256SUMS ]; then
_pv_stems=$(sed -n 's|.*[ ]||p' /data/SHA256SUMS 2>/dev/null | sed -n 's|\.tar\.zst$||p' | sort -u)
fi
_pvv=$(payload_verdict "${_id_name:-}" "$_pv_stems")
case "$_pvv" in
PASS*) pass identity-payload "${_pvv#PASS }" ;;
SKIP*) skip identity-payload "${_pvv#SKIP }" ;;
*) fail identity-payload "${_pvv#FAIL }" ;;
esac
if [ -f /data/SHA256SUMS ]; then
if (cd /data && sha256sum -c SHA256SUMS >/dev/null 2>&1); then pass sha256sums "/data/SHA256SUMS verifies"
else fail sha256sums "/data/SHA256SUMS does not verify (cd /data && sha256sum -c SHA256SUMS)"; fi
Expand Down
12 changes: 12 additions & 0 deletions os/v3/puppy/container-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,19 @@ if [ -n "${PAYLOAD:-}" ]; then
"$skeleton/etc/1bit/onebit-models.txt" || {
echo "build: REFUSED: could not write /etc/1bit/onebit-models.txt from the payload catalogue" >&2
exit 1; }
# engine#1557: `payload=` names the payload, and a name is only a claim. This records a fact about the same
# /payload tree - the sorted list of its file paths - so release-check can compare the identity with the tree
# the image actually carries. Cheap on both sides (metadata only, and the image-side walk already happens for
# the payload-modes row), and it needs no packer: the build is what has the payload, so the build is the writer.
# The payload's own identity, algorithmically: relative file paths, sorted, hashed. release-check.sh recomputes it
# over /opt/1bit-package with the SAME expression (grep for "engine#1557" there); the two must stay identical, which
# is why it is one line of find|sed|sort|sha256sum and not a script.
payload_manifest() { # <payload dir>
find "$1" -type f 2>/dev/null | sed "s|^$1/||" | LC_ALL=C sort | sha256sum | cut -d' ' -f1
}

{ echo "payload=${PAYLOAD_NAME:-unknown}"
echo "payload_manifest=$(payload_manifest /payload)"
echo "engine_sha256=$(sha256sum /payload/1bit/1bit | cut -c1-64)"
if [ -n "${LIBHSA_DIR:-}" ]; then
echo "libhsa_sha256=$(sha256sum /libhsa-runtime/libhsa-runtime64.so.1 | cut -c1-64)"
Expand Down
Loading