From f1a25feafde8d98a74839464c4f17045476ccf27 Mon Sep 17 00:00:00 2001 From: diviocity Date: Mon, 30 Nov 2026 03:58:12 +0100 Subject: [PATCH] Exercise BusyBox wget trust and hostname checks in Vinix --- BOOTSTRAP.md | 2 ++ tests/userland/wget.sh | 55 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 tests/userland/wget.sh diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md index cf73987..629e796 100644 --- a/BOOTSTRAP.md +++ b/BOOTSTRAP.md @@ -73,4 +73,6 @@ Each port gets a fresh, signed SDK containing its transitive prerequisites. The The published x86_64 Vinix kernel booted 32 signed network packages. It refreshed the trust store with a local CA, established loopback HTTPS, rejected the wrong hostname, committed and read a Git file, signed and verified that file with the installed SSH tools, then installed and queried a local XBPS package. The fixture and logs are `tests/userland/network.sh` and `foundation/network-guest-03`, receipt SHA-256 `4e9afac33947b999911a4ff35f218b49f3356b345e47e7b90e7ffce644d0c7b4`. +An eight-package x86_64 guest tested the BusyBox wget applet and its separately packaged TLS helper. It rejected an unknown certificate, retrieved the expected bytes after installing the local CA, and rejected the same certificate for a different hostname. The guest fixture is `tests/userland/wget.sh`. The worker keeps the install, audit and serial hashes in `foundation/wget-guest-x86_64-01/receipts.sha256`, SHA-256 `5872d1467ee2594b9305bed5fa1ceb084c8c3fde4ebccb0539db25d02b3849f9`. + For package roots too large for a test initramfs, use `python3 tests/disk-root.py "$arch" "$root" "$fixture" "$iso" "$boot" "$output"` on the worker. The root must supply BusyBox init, and the fixture prints `VPAC FIXTURE GUEST PASS` after its checks. The helper creates a fresh ext2 image file from a private copy and runs QEMU in snapshot mode. The x86_64 release kernel read the matching disk identity and relocated all 109 dynamic executable paths from a 106-package root with 512 MiB of guest RAM. The test retains its ext2 and serial hashes under `foundation/disk-exec-x86-02/test`, receipt SHA-256 `6f600855744d04fa71d916f545e746ed36ba2686a56937c2b4c3cb02e3ec6a58`. diff --git a/tests/userland/wget.sh b/tests/userland/wget.sh new file mode 100644 index 0000000..3b3a3c2 --- /dev/null +++ b/tests/userland/wget.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# Exercise the release BusyBox applet and the installed TLS helper inside Vinix. +set -eu +export PATH=/bin:/usr/bin:/sbin:/usr/sbin HOME=/tmp LC_ALL=C +unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY SSL_CERT_FILE SSL_CERT_DIR +phase=identity +server= +finish() { + status=$? + if [ -n "$server" ]; then kill "$server" 2>/dev/null || true; fi + if [ "$status" -ne 0 ]; then echo "VPAC WGET FAIL at $phase with status $status"; fi + /sbin/poweroff -f +} +trap finish EXIT +test "$(uname -o)" = Vinix +test -x /usr/bin/ssl_client +mkdir -p /tmp/wget/empty +cd /tmp/wget +printf '\n127.0.0.1 vinix.test wrong.test\n' >>/etc/hosts +printf 'Signed Vinix networking packages\n' >body.txt +openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -days 1 \ + -subj /CN=vinix.test -addext subjectAltName=DNS:vinix.test -keyout key.pem -out cert.pem +openssl s_server -accept 127.0.0.1:21443 -cert cert.pem -key key.pem -WWW >server.log 2>&1 & +server=$! + +phase=trusted-peer +url=https://vinix.test:21443/body.txt +tries=0 +until SSL_CERT_FILE="$PWD/cert.pem" SSL_CERT_DIR="$PWD/empty" \ + /bin/busybox wget -T 5 -O received "$url" >client.log 2>&1; do + tries=$((tries + 1)) + if [ "$tries" -ge 5 ]; then cat client.log server.log; exit 1; fi + sleep 1 +done +cmp body.txt received + +phase=untrusted-ca +if /bin/busybox wget -T 5 -O rejected "$url" >client.log 2>&1; then exit 1; fi +cat client.log +grep -Eiq 'certificate verify failed|certificate verification failed' client.log +test ! -s rejected + +phase=system-store +mkdir -p /usr/local/share/ca-certificates +cp cert.pem /usr/local/share/ca-certificates/vinix-fixture.crt +update-ca-certificates +/bin/busybox wget -T 5 -O received "$url" +cmp body.txt received + +phase=wrong-hostname +if /bin/busybox wget -T 5 -O wrong https://wrong.test:21443/body.txt >client.log 2>&1; then exit 1; fi +cat client.log +grep -Eiq 'hostname mismatch|certificate verify failed|certificate verification failed' client.log +test ! -s wrong +echo 'VPAC FIXTURE GUEST PASS' -- 2.56.1