me

/

vinix-ports Public
382 commits 0 issues 0 pull requests 1 contributor Discussions Projects Snippets LOC history Platform CI

Exercise a signed pkg upgrade over HTTPS in QEMU

diviocity committed 5 days ago · c7be15b1dad9105fc7c7414ec161b2c90b4a17f6 View patch
Unverified signature 3 files changed +55 -8
tests/FEED.md +2 -0

@@ -225,6 +225,8 @@ For the public `pkg` command, install `vinix-pkg`, `busybox-init`, `vinix-keyrin

225225

226226Run `vpac-guest.py` with `--scenario upgrade --package-command pkg` to exercise the public upgrade path. The initial feed needs `vinix-pkg`. Pass `--staged-root "$image/root"` to reuse a clean staged image from the same signed feed on the build volume. The x86_64 replay upgraded the CA bundle to `20261020-3` and checked the signature validation record, the new certificate link and its owner. The original staged root retained release 2. The runner rejected a staged root with a different signed database before creating a guest image. See `foundation/vinix-pkg-upgrade-01` and `foundation/vinix-pkg-upgrade-mismatched-root-01`, receipt SHA-256 `efa7b96701b2f2aeb7afd3ac8398adb3859b818d1dbf90efc1856e44f9059038` and `b670332301bc1005b8dff21a1a6e4342147015a9e6723da2e0b09ddd35f3fe7b`.

227227

228+Add `--upgrade-https` to serve the signed update on guest loopback TLS and switch the disposable guest's vpac repository URL to that endpoint. The fixture uses the packaged curl and OpenSSL, and the upgrade checks vpac's signature validation record with the normal package and database signature requirements enabled. With `--signed-update "$previous_update_feed"`, the runner compares the existing signed package against the build receipt before staging it and its indexes. The first x86_64 HTTPS run installed the signed update on the candidate kernel. Its test disk and roots can be restored using `replay.sha256` and `restore-paths` in `foundation/ports-candidate-https-upgrades-02/amd64`, archive evidence SHA-256 `a9835ee287eaca1832782f70d46c4a59438751230a7955178b1bd41cfde7679f`.

229+

228230The original ext2 files from `vinix-pkg-guest-01`, `vinix-pkg-upgrade-01` and `vpac-transaction-08` are compressed in `foundation/archived-pkg-fixture-disks-01`. Its `restore.tsv` gives their original paths, uncompressed checksums, modes and timestamps. Restore each needed file with `zstd -d --sparse` before rerunning its disk receipt checks. Each expanded archive matched the original checksum before relocation. The archive receipt manifest has SHA-256 `c5b49fbb69cddfe2fcb3828cd1b7316d48b4f1ef90a155fa369f2ba63a32bbf9`.

229231

230232To 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`.

tests/userland/vpac.sh +34 -1

@@ -3,8 +3,10 @@

33set -eu

44export PATH=/bin:/usr/bin:/sbin:/usr/sbin LC_ALL=C HOME=/root

55phase=identity

6+tls_server=

67finish() {

78 status=$?

9+ if [ -n "$tls_server" ]; then kill "$tls_server" 2>/dev/null || true; fi

810 if [ "$status" -ne 0 ]; then echo "VPAC TRANSACTION FAIL at $phase with status $status"; fi

911 /sbin/poweroff -f

1012}

@@ -92,7 +94,35 @@ reference=/var/lib/vinix/test-update

9294test ! -e /etc/ssl1.1/cert.pem

9395vpac q -F version local/ca-certificates-bundle >/tmp/bundle

9496grep -Eq '^version[[:space:]]+20261020-2$' /tmp/bundle

95-cp "$reference/"* "/var/lib/vinix/repository/$arch/"

97+if [ "${VPAC_TEST_UPGRADE_HTTPS:-0}" = 1 ]; then

98+ phase=upgrade-https-setup

99+ unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY SSL_CERT_FILE SSL_CERT_DIR

100+ tls=$(mktemp -d /tmp/vpac-fixture-tls.XXXXXX)

101+ openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -days 1 \

102+ -subj /CN=127.0.0.1 -addext subjectAltName=IP:127.0.0.1 \

103+ -keyout "$tls/key.pem" -out "$tls/cert.pem"

104+ (

105+ cd "$reference"

106+ exec openssl s_server -accept 127.0.0.1:28443 -cert "$tls/cert.pem" -key "$tls/key.pem" -WWW

107+ ) >"$tls/server.log" 2>&1 &

108+ tls_server=$!

109+ url=https://127.0.0.1:28443

110+ tries=0

111+ until curl --disable --noproxy '*' --fail --silent --show-error --max-time 5 \

112+ --cacert "$tls/cert.pem" "$url/vinix.db" -o "$tls/remote.db" >"$tls/client.log" 2>&1; do

113+ tries=$((tries + 1))

114+ if [ "$tries" -ge 5 ]; then cat "$tls/client.log" "$tls/server.log"; exit 1; fi

115+ sleep 1

116+ done

117+ cmp "$reference/vinix.db" "$tls/remote.db"

118+ trust_hash=$(openssl x509 -in "$tls/cert.pem" -noout -subject_hash)

119+ cp "$tls/cert.pem" "/etc/ssl/certs/$trust_hash.0"

120+ sed -i "s|file:///var/lib/vinix/repository/$arch|$url|" /etc/vpac.d/config.vile

121+ grep -Fq "$url" /etc/vpac.d/config.vile

122+else

123+ cp "$reference/"* "/var/lib/vinix/repository/$arch/"

124+fi

125+phase=upgrade

96126if [ "$package_command" = pkg ]; then

97127 pkg upgrade

98128else

@@ -107,4 +137,7 @@ phase=upgraded-files

107137test "$(readlink /etc/ssl1.1/cert.pem)" = ../ssl/cert.pem

108138cmp /etc/ssl1.1/cert.pem /etc/ssl/certs/ca-certificates.crt

109139vpac o /etc/ssl1.1/cert.pem | grep -q ca-certificates-bundle

140+if [ "${VPAC_TEST_UPGRADE_HTTPS:-0}" = 1 ]; then

141+ echo 'VPAC upgraded a signed package over HTTPS'

142+fi

110143echo 'VPAC FIXTURE GUEST PASS'

tests/vpac-guest.py +19 -7

@@ -56,9 +56,14 @@ def run(args):

5656 with new.open("rb") as stream:

5757 if hashlib.file_digest(stream, "sha256").hexdigest() != digest:

5858 raise ValueError("update archive differs from its build receipt")

59- update = work / "update"

60- siblings = sorted(path for path in initial.glob("*.pkg.tar.zst") if path != old)

61- log("publish-update", ["feed", "publish", args.keys, update, arch, new, *siblings])

59+ update = args.signed_update or work / "update"

60+ if args.signed_update:

61+ with (update / arch / filename).open("rb") as stream:

62+ if hashlib.file_digest(stream, "sha256").hexdigest() != digest:

63+ raise ValueError("reused signed update differs from its build receipt")

64+ else:

65+ siblings = sorted(path for path in initial.glob("*.pkg.tar.zst") if path != old)

66+ log("publish-update", ["feed", "publish", args.keys, update, arch, new, *siblings])

6267 delta = root / "var/lib/vinix/test-update"

6368 delta.mkdir()

6469 delta.chmod(0o755)

@@ -69,13 +74,14 @@ def run(args):

6974 target.chmod(0o644)

7075

7176 fixture = work / "fixture.sh"

72- fixture.write_bytes(f"VPAC_TEST_SCENARIO={args.scenario}\nVPAC_TEST_PACKAGE_COMMAND={args.package_command}\n".encode()

73- + (tests / "userland/vpac.sh").read_bytes())

77+ settings = (f"VPAC_TEST_SCENARIO={args.scenario}\nVPAC_TEST_PACKAGE_COMMAND={args.package_command}\n"

78+ f"VPAC_TEST_UPGRADE_HTTPS={int(args.upgrade_https)}\n")

79+ fixture.write_bytes(settings.encode() + (tests / "userland/vpac.sh").read_bytes())

7480 disk = work / "disk"

7581 env = os.environ.copy()

7682 env.setdefault("VINIX_QEMU_TIMEOUT", "720")

7783 log("boot", [sys.executable, tests / "disk-root.py", arch, root, fixture,

78- args.iso, args.boot, disk], env=env)

84+ args.iso, args.boot, disk, "--link-inputs"], env=env)

7985 files = sorted(work.glob("*.log")) + [fixture, disk / "guest/serial.log", disk / "receipts.sha256"]

8086 with (work / "receipts.sha256").open("x") as report:

8187 for file in files:

@@ -88,8 +94,14 @@ if __name__ == "__main__":

8894 parser.add_argument("arch", choices=("x86_64", "aarch64"))

8995 parser.add_argument("--scenario", choices=("all", "install", "upgrade"), default="all")

9096 parser.add_argument("--package-command", choices=("vpac", "pkg"), default="vpac")

97+ parser.add_argument("--upgrade-https", action="store_true", help="serve the signed upgrade over guest loopback TLS")

98+ parser.add_argument("--signed-update", type=lambda path: Path(path).resolve(),

99+ help="reuse an existing signed update repository with the exact upgrade archive")

91100 parser.add_argument("--staged-root", type=lambda path: Path(path).resolve(),

92101 help="reuse a staged root from the same feed and build volume")

93102 for option in ("repo", "keys", "fingerprint", "update_receipt", "auditor", "boot", "iso", "work"):

94103 parser.add_argument(option, type=lambda path: Path(path).resolve())

95- run(parser.parse_args())

104+ args = parser.parse_args()

105+ if args.upgrade_https and args.scenario == "install":

106+ parser.error("--upgrade-https requires an upgrade scenario")

107+ run(args)