Verify signed vpac installs and upgrades in Vinix guests
@@ -80,7 +80,7 @@ The published x86_64 Vinix kernel booted that 22-package root. Both `gpgv` and t
8080
8181The x86_64 vpac recipe uses V at `597b0f6`, targets musl explicitly, and embeds the Vile resources. Its configuration check temporarily removes both input Scheme files and queries an installed signed musl record. The recipe uses the locked `nobody` account from `vinix-accounts` and keeps package and database signature checks enabled. The build peaked at 2,281,107,456 bytes with zero cgroup OOM events. The resulting `vpac-1.0.0-1-x86_64.pkg.tar.zst` has SHA-256 `f6aa20508a8bc62b5da8b5134657f8d12b1ff5c1609a87e2d7eae02759ea7786`. The worker recorded the pinned source trees in `foundation/vpac-vcs-pins-01`, receipt SHA-256 `2124cc24c72459f7274eb4a74c0d1fa4ec30896a35183e31e6786e9060666014`.
8282
83-Release 2 handles the Vinix kernel's `ENOSYS` response to the Landlock ABI query. Downloads retain the locked account, no-new-privs and seccomp, and the transaction still verifies the signed package. The x86_64 guest refused a same-length modification of the signed netbase archive, installed the authentic archive, and verified its local owner and signature. A separate boot queried the signed repository record by exact name. See `foundation/vpac-transaction-08/disk/guest/serial.log` and `foundation/vpac-remote-query-01/disk/receipts.sha256`, receipt SHA-256 `0d0569ad76f9828fadac877bf1f67ae505eceab3231546b30a13423826f48891`. The combined test still times out during repository lookup after installation. The upgrade fixture reaches package verification and extraction and still needs to pass its post-upgrade checks.
83+Release 2 handles the Vinix kernel's `ENOSYS` response to the Landlock ABI query. Downloads retain the locked account, no-new-privs and seccomp, and the transaction still verifies the signed package. The x86_64 install scenario refused a same-length modification of the signed netbase archive, installed the authentic archive, and verified its owner, signature and repository lookup. The separate upgrade scenario installed CA bundle release 3 over release 2 and verified the new record, signature, symlink, contents and owner. See `foundation/vpac-install-scenario-01` and `foundation/vpac-upgrade-runtime-01/replay`, receipt SHA-256 `8aadaa39401e58548c4df2d50cc7147277df26d51a92920d23bf3cf7cdace8f5` and `e3dbc2800cabf2cee08dc91a2a7656e3ec031860da4a3a796fc0c917fab5866b`. The combined x86_64 replay reported a completed upgrade and timed out before the fixture passed. The AArch64 target-vpac trials remain pending.
8484
8585For later builds, `tools/build-queue.py` uses the source order and a verified bootstrap feed. Place the input archives and a `NAME.sha256` receipt for each in `$work/artifacts`. Configure the host compiler and signing tools as for a single native build, then select the ports to build. The worker uses this command form.
8686
@@ -155,4 +155,6 @@ Changing the netbase archive after signing caused assembly to fail its signed in
155155
156156The installed-root auditor checks each nonempty ELF load segment against the released kernel page size, 4 KiB on x86_64 and 16 KiB on aarch64. It also checks required symbol-version namespaces against the actual resolved package-owned provider using GNU readelf and objdump. The 106-package x86_64 root and the corrected arm64 loader passed. An old arm64 BusyBox failed its segment congruence check. An x86_64 libcrypto with its original SONAME and a changed version tag failed the OpenSSL consumer check. See `foundation/load-and-versions-02`, receipt SHA-256 `fd32f6b69db215ff6b79ec1f58c8457cf7f514dd162fbde410d9f6882072b979`. Use `tests/exec-linkage.py` as well to exercise actual dynamic symbol resolution.
157157
158+Run the target vpac binary on the release kernel with `python3 tests/vpac-guest.py "$arch" "$repo" "$test_keys" "$fingerprint_file" "$update_receipt" "$auditor" "$boot" "$iso" "$output"`. Use a signed initial feed containing netbase and CA bundle release 2 and pass the receipt for CA bundle release 3. The guest has no network interface. The fixture tests a same-length package modification, authentic installation, local and remote lookup, and a signed in-place upgrade. Pass `--scenario install` or `--scenario upgrade` to replay either operation on a fresh copy of the same image inputs. The runner defaults to 720 seconds under QEMU TCG. `VINIX_QEMU_TIMEOUT` overrides that limit in seconds.
159+
158160To exercise the original release binaries against the installed libraries on a worker of the same architecture, run `python3 tests/exec-linkage.py "$arch" "$client" "$auditor" --proot "$proot" --release "$archive" "$sha256" "$report"`. The probe binds one original executable over its guest path and runs the installed musl loader with `--list`. A negative control changed a library import in the original input and verified that the installed loader diagnosed the changed SONAME. In the 129-package x86_64 root, 52 of 95 dynamic image executables relocated, 27 reported failures and 16 fixed-address executables needed direct execution. Twelve of 17 X11 sidecar executables relocated. See `foundation/release-binary-relocation-02`, receipt SHA-256 `8483666ef4294f1ac5d44c1eb637a8f5200be4e613e635d835ef4f86e7ffa37b`. Directly starting the release `cpp` and `cc1` in that root expanded `__SIZEOF_POINTER__` to 8. See `foundation/release-original-exec-02`, receipt SHA-256 `b9f1659e4669df9f3d4aeddea37fd9b85abc40f9d55045fff1fc7096f091a209`.
@@ -4,6 +4,7 @@ module main
44
55import crypto.sha256
66import os
7+import strconv
78
89fn run(argv []string) ! {
910 result := os.exec(argv)
@@ -13,6 +14,12 @@ fn run(argv []string) ! {
1314}
1415
1516fn boot_image(root string, iso string, output string, mode string, fixture string, disk string) ! {
17+ deadline := strconv.atoi(os.getenv_opt('VINIX_QEMU_TIMEOUT') or { '120' }) or {
18+ return error('VINIX_QEMU_TIMEOUT must be a positive integer in seconds')
19+ }
20+ if deadline <= 0 {
21+ return error('VINIX_QEMU_TIMEOUT must be a positive integer in seconds')
22+ }
1623 shell := mode == '--shell'
1724 arm := mode.starts_with('--aarch64-')
1825 userland := mode in ['--userland', '--aarch64-userland'] || fixture != ''
@@ -127,7 +134,7 @@ fn boot_image(root string, iso string, output string, mode string, fixture strin
127134 }
128135 emulator << ['-accel', 'tcg', '-cpu', 'max', '-m', memory, '-smp', '2', '-nic', 'none', '-display',
129136 'none', '-monitor', 'none', '-serial', 'file:' + log, '-no-reboot']
130- run(['timeout', '120s', ...emulator])!
137+ run(['timeout', '${deadline}s', ...emulator])!
131138 lines := os.read_lines(log)!.map(it.trim_space())
132139 if disk != '' {
133140 id := os.read_file(os.join_path(root, '.vinix-image-id'))!.trim_space()
@@ -0,0 +1,91 @@
1+#!/bin/sh
2+# Boot a root with target vpac installed and netbase available only in the embedded feed.
3+set -eu
4+export PATH=/bin:/usr/bin:/sbin:/usr/sbin LC_ALL=C HOME=/root
5+phase=identity
6+finish() {
7+ status=$?
8+ if [ "$status" -ne 0 ]; then echo "VPAC TRANSACTION FAIL at $phase with status $status"; fi
9+ /sbin/poweroff -f
10+}
11+trap finish EXIT
12+test "$(uname -o)" = Vinix
13+mkdir -p /tmp
14+vpac q -F name,validation local/musl >/tmp/musl
15+grep -Eq '^validation[[:space:]]+signature$' /tmp/musl
16+vpac o /bin/busybox | grep -q busybox
17+arch=$(uname -m)
18+install_test() {
19+ test ! -e /etc/services
20+ set -- /var/lib/vinix/repository/"$arch"/netbase-[0-9]*.pkg.tar.zst
21+ test "$#" -eq 1 && test -s "$1"
22+ archive=$1
23+
24+ phase=reject
25+ cp "$archive" /tmp/netbase-original
26+ # Change the Zstd magic without changing the signed archive's byte count.
27+ printf '\000' | dd of="$archive" bs=1 count=1 conv=notrunc 2>/dev/null
28+ test "$(wc -c <"$archive")" = "$(wc -c </tmp/netbase-original)"
29+ if cmp -s "$archive" /tmp/netbase-original; then exit 1; fi
30+ status=0
31+ vpac i --noconfirm netbase >/tmp/reject.log 2>&1 || status=$?
32+ cat /tmp/reject.log
33+ test "$status" -ne 0
34+ grep -Fiq 'invalid or corrupted package (PGP signature)' /tmp/reject.log
35+ test ! -e /etc/services
36+ for record in /var/lib/vpac/local/netbase-*; do test ! -d "$record"; done
37+ mv /tmp/netbase-original "$archive"
38+
39+ phase=install
40+ vpac i --noconfirm netbase
41+ echo 'VPAC transaction installed authentic netbase'
42+ phase=installed-ownership
43+ vpac o /etc/services | grep -q netbase
44+ phase=installed-record
45+ vpac q -F name,validation local/netbase >/tmp/netbase
46+ grep -Eq '^name[[:space:]]+netbase$' /tmp/netbase
47+ grep -Eq '^validation[[:space:]]+signature$' /tmp/netbase
48+ grep -Eq '^ssh[[:space:]]+22/tcp' /etc/services
49+
50+ echo 'VPAC transaction verified installed owner and signature'
51+ phase=remote-record
52+ vpac q --noconfirm -F name,version vinix/netbase >/tmp/exact
53+ grep -Eq '^name[[:space:]]+netbase$' /tmp/exact
54+ echo 'VPAC transaction resolved the exact repository record'
55+ phase=local-search
56+ vpac s --noconfirm --local --quiet netbase >/tmp/local-names
57+ grep -Fxq netbase /tmp/local-names
58+ echo 'VPAC transaction searched installed packages'
59+ phase=remote-search
60+ vpac s --noconfirm --remote --quiet netbase >/tmp/remote-names
61+ grep -Fxq netbase /tmp/remote-names
62+ vpac s --noconfirm --remote --quiet vinix-fixture-absent-port >/tmp/unknown
63+ test ! -s /tmp/unknown
64+
65+ echo 'VPAC transaction verified package lookup'
66+}
67+
68+mode=${VPAC_TEST_SCENARIO:-all}
69+case "$mode" in
70+ install) install_test; echo 'VPAC FIXTURE GUEST PASS'; exit 0 ;;
71+ all) install_test ;;
72+ upgrade) ;;
73+ *) echo "unknown test scenario $mode" >&2; exit 2 ;;
74+esac
75+phase=upgrade
76+reference=/var/lib/vinix/test-update
77+test ! -e /etc/ssl1.1/cert.pem
78+vpac q -F version local/ca-certificates-bundle >/tmp/bundle
79+grep -Eq '^version[[:space:]]+20261020-2$' /tmp/bundle
80+cp "$reference/"* "/var/lib/vinix/repository/$arch/"
81+vpac u --sync --noconfirm
82+phase=upgraded-record
83+vpac q -F version,validation local/ca-certificates-bundle >/tmp/upgraded
84+grep -Eq '^version[[:space:]]+20261020-3$' /tmp/upgraded
85+grep -Eq '^validation[[:space:]]+signature$' /tmp/upgraded
86+test ! -d /var/lib/vpac/local/ca-certificates-bundle-20261020-2
87+phase=upgraded-files
88+test "$(readlink /etc/ssl1.1/cert.pem)" = ../ssl/cert.pem
89+cmp /etc/ssl1.1/cert.pem /etc/ssl/certs/ca-certificates.crt
90+vpac o /etc/ssl1.1/cert.pem | grep -q ca-certificates-bundle
91+echo 'VPAC FIXTURE GUEST PASS'
@@ -0,0 +1,76 @@
1+"""Boot a staged vpac image and test rejection, install and upgrade using the guest binary."""
2+import argparse
3+import hashlib
4+import os
5+import shutil
6+import subprocess
7+import sys
8+from pathlib import Path
9+
10+
11+def run(args):
12+ work = args.work
13+ work.mkdir()
14+ arch = args.arch
15+ tests = Path(__file__).resolve().parent
16+ pin = args.fingerprint.read_text().strip()
17+ trust = work / "client-keys"
18+ repo = args.repo
19+ client = work / "client"
20+ image = work / "image"
21+
22+ def log(name, argv, **options):
23+ with (work / (name + ".log")).open("x") as output:
24+ subprocess.run(argv, stdout=output, stderr=subprocess.STDOUT, check=True, **options)
25+
26+ log("trust", ["feed", "trust", trust, repo / "test-signer.asc", pin])
27+ log("install", ["feed", "install", trust, repo, arch, client, "--fakeroot",
28+ "vpac", "busybox-init", "vinix-keyring", "vinix-accounts", "vinix-filesystem"])
29+ log("stage", [sys.executable, tests.parent / "tools/stage-image.py", arch, client, repo,
30+ image, args.auditor, pin])
31+
32+ # The updater receives a second complete signed index. Only its changed files
33+ # have to be added to the guest image alongside the first verified snapshot.
34+ root = image / "root"
35+ initial = root / "var/lib/vinix/repository" / arch
36+ old = initial / "ca-certificates-bundle-20261020-2-any.pkg.tar.zst"
37+ if not old.is_file() or not list(initial.glob("netbase-*.pkg.tar.zst")):
38+ raise ValueError("initial feed needs CA bundle release 2 and netbase")
39+ digest, filename = args.update_receipt.read_text().strip().split()
40+ if filename != "ca-certificates-bundle-20261020-3-any.pkg.tar.zst":
41+ raise ValueError("expected CA bundle release 3 in the update receipt")
42+ new = args.update_receipt.parent / filename
43+ with new.open("rb") as stream:
44+ if hashlib.file_digest(stream, "sha256").hexdigest() != digest:
45+ raise ValueError("update archive differs from its build receipt")
46+ update = work / "update"
47+ siblings = sorted(path for path in initial.glob("*.pkg.tar.zst") if path != old)
48+ log("publish-update", ["feed", "publish", args.keys, update, arch, new, *siblings])
49+ delta = root / "var/lib/vinix/test-update"
50+ delta.mkdir()
51+ for base in ("vinix.db", "vinix.files", new.name):
52+ for name in (base, base + ".sig"):
53+ shutil.copyfile(update / arch / name, delta / name)
54+
55+ fixture = work / "fixture.sh"
56+ fixture.write_bytes(f"VPAC_TEST_SCENARIO={args.scenario}\n".encode()
57+ + (tests / "userland/vpac.sh").read_bytes())
58+ disk = work / "disk"
59+ env = os.environ.copy()
60+ env.setdefault("VINIX_QEMU_TIMEOUT", "720")
61+ log("boot", [sys.executable, tests / "disk-root.py", arch, root, fixture,
62+ args.iso, args.boot, disk], env=env)
63+ files = sorted(work.glob("*.log")) + [fixture, disk / "guest/serial.log", disk / "receipts.sha256"]
64+ with (work / "receipts.sha256").open("x") as report:
65+ for file in files:
66+ with file.open("rb") as stream:
67+ report.write(f"{hashlib.file_digest(stream, 'sha256').hexdigest()} {file.relative_to(work)}\n")
68+
69+
70+if __name__ == "__main__":
71+ parser = argparse.ArgumentParser(description=__doc__)
72+ parser.add_argument("arch", choices=("x86_64", "aarch64"))
73+ parser.add_argument("--scenario", choices=("all", "install", "upgrade"), default="all")
74+ for option in ("repo", "keys", "fingerprint", "update_receipt", "auditor", "boot", "iso", "work"):
75+ parser.add_argument(option, type=lambda path: Path(path).resolve())
76+ run(parser.parse_args())