From c3731b2aba091a48e212aa203a7b7926d9ba66b6 Mon Sep 17 00:00:00 2001 From: diviocity Date: Mon, 30 Nov 2026 03:53:08 +0100 Subject: [PATCH] Build Xvfb and verify authenticated clients in the release kernel --- tests/x11/README.md | 2 ++ tests/x11/headless.sh | 39 ++++++++++++++++++++++++++++++++++++++ xorg-server/configure.v | 42 +++++++++++++++++++++++++++++++++++++++++ xvfb/PKGBUILD.vile | 32 +++++++++++++++++++++++++++++++ xvfb/configure.v | 1 + 5 files changed, 116 insertions(+) create mode 100644 tests/x11/headless.sh create mode 100644 xorg-server/configure.v create mode 100644 xvfb/PKGBUILD.vile create mode 120000 xvfb/configure.v diff --git a/tests/x11/README.md b/tests/x11/README.md index 8eddc55..eed8695 100644 --- a/tests/x11/README.md +++ b/tests/x11/README.md @@ -32,3 +32,5 @@ v run tests/x11/release-elf.v "$release_assets" "$reference_apks" "$new_output" The x86-64 client test booted Vinix with ten PGP-validated packages, including libX11, libfontenc and Pixman. `client.v` parsed a signed X geometry, mapped the Latin-9 euro character to Unicode and copied a one-pixel ARGB image through Pixman. All three checks passed. Its additional `--display` mode performs a pixmap readback against a running X server. The font test installed `mkfontscale` and both bitmap font packages by name. The cold install ran the pacman hook inside the target root and produced 766 owned file and link paths across twelve signed packages. Inside Vinix, `font-index.v` ran the installed hook’s command with the cursor font present, removed and restored. It verified the header count, the cursor entry and the fixed-font entry. Both QEMU runs used one vCPU and 384 MiB. Receipts and serial transcripts are under `~/.local/state/vinix/ports/musl-busybox-CqkBEA/xorg/worker/{x11-client-guest-04,font-index-guest-02}`. + +The headless server test installed `xvfb`, `xauth`, `xset`, `xrdb` and BusyBox by name. The x86-64 root contained 36 PGP-validated packages, 5,738 owned file and link paths and 68 target ELFs. On the release kernel, `headless.sh` started the packaged Xvfb with TCP disabled, authenticated a client, drew a pixmap and checked the returned pixel. The client also wrote and read back an X resource. A new connection with an empty authority file correctly failed. The 384 MiB, one-vCPU guest transcript and ISO checksum are under `~/.local/state/vinix/ports/musl-busybox-CqkBEA/xorg/worker/guest-xvfb-03`. diff --git a/tests/x11/headless.sh b/tests/x11/headless.sh new file mode 100644 index 0000000..10b8379 --- /dev/null +++ b/tests/x11/headless.sh @@ -0,0 +1,39 @@ +#!/bin/sh +set -eu +export PATH=/bin:/usr/bin:/sbin:/usr/sbin HOME=/tmp +export DISPLAY=:71 XAUTHORITY=/tmp/vinix-x11.Xauthority +server= +finish() { + status=$? + if [ "$status" -ne 0 ]; then + echo 'Vinix headless X11 guest check failed' + if [ -f /tmp/xvfb.log ]; then cat /tmp/xvfb.log; fi + fi + if [ -n "$server" ]; then kill "$server" 2>/dev/null || true; fi + /sbin/poweroff -f +} +trap finish EXIT +mkdir -p /tmp +# This fixed cookie belongs to an isolated guest display with TCP disabled. +xauth -q -f "$XAUTHORITY" add "$DISPLAY" MIT-MAGIC-COOKIE-1 0123456789abcdef0123456789abcdef +Xvfb "$DISPLAY" -auth "$XAUTHORITY" -nolisten tcp -noreset -screen 0 128x128x24 >/tmp/xvfb.log 2>&1 & +server=$! +attempt=0 +until xset q >/tmp/xset.log 2>&1; do + kill -0 "$server" + attempt=$((attempt + 1)) + [ "$attempt" -lt 20 ] + sleep 1 +done +/x11-client --display +printf 'Vinix.sidecar: tested\n' >/tmp/xresources +xrdb -nocpp -load /tmp/xresources +xrdb -query >/tmp/xresources-query +grep -E '^Vinix\.sidecar:[[:space:]]*tested$' /tmp/xresources-query +: >/tmp/empty.Xauthority +if XAUTHORITY=/tmp/empty.Xauthority xset q >/tmp/unauthorized.log 2>&1; then + echo 'Xvfb accepted an unauthenticated client' + exit 1 +fi +echo 'Packaged Xvfb, Xauth, Xlib, xset and xrdb guest checks passed.' +echo 'VPAC FIXTURE GUEST PASS' diff --git a/xorg-server/configure.v b/xorg-server/configure.v new file mode 100644 index 0000000..9a176a3 --- /dev/null +++ b/xorg-server/configure.v @@ -0,0 +1,42 @@ +// Configure the two X server profiles shipped in Vinix's X11 sidecar. +module main + +import os + +fn configure(profile string, source string, build string) ! { + if profile !in ['headless', 'accelerated'] { + return error('expected the headless or accelerated X server profile') + } + root := os.getenv('VPAC_MAKEPKG_ROOT') + if !os.is_abs_path(root) { + return error('set VPAC_MAKEPKG_ROOT to the staged target SDK') + } + script := os.abs_path(os.join_path(source, 'configure')) + os.mkdir_all(build)! + os.chdir(build)! + os.setenv('CPPFLAGS', (os.getenv('CPPFLAGS') + ' -D__vinix__').trim_space(), true) + os.setenv('LDFLAGS', (os.getenv('LDFLAGS') + ' -Wl,-rpath-link,' + root + '/usr/lib -rdynamic').trim_space(), true) + mut args := [script, '--localstatedir=/var', '--with-xkb-bin-directory=/usr/bin', + '--with-xkb-path=/usr/share/X11/xkb', '--with-xkb-output=/var/lib/xkb', + '--with-fontrootdir=/usr/share/fonts/X11', '--enable-xvfb', '--disable-xephyr', + '--disable-xnest', '--disable-suid-wrapper', '--disable-pciaccess', '--disable-dpms', + '--disable-xres', '--disable-xvmc', '--disable-systemd-logind', '--disable-secure-rpc', + '--disable-config-udev', '--disable-dri', '--disable-dri2', '--disable-int10-module', + '--disable-vgahw', '--disable-xinerama', '--enable-screensaver'] + setting := if profile == 'accelerated' { '--enable-' } else { '--disable-' } + for feature in ['xorg', 'dri3', 'libdrm', 'glamor', 'glx'] { + args << setting + feature + } + os.execvp('vinix-configure', args)! +} + +fn main() { + if os.args.len != 4 { + eprintln('usage: configure.v PROFILE XORG_SOURCE BUILD_DIRECTORY') + exit(2) + } + configure(os.args[1], os.args[2], os.args[3]) or { + eprintln(err) + exit(1) + } +} diff --git a/xvfb/PKGBUILD.vile b/xvfb/PKGBUILD.vile new file mode 100644 index 0000000..0700744 --- /dev/null +++ b/xvfb/PKGBUILD.vile @@ -0,0 +1,32 @@ +defpkgbuild(xvfb, + #:pkgname, "xvfb", + #:pkgver, "21.1.16", + #:pkgrel, 2, + #:pkgdesc, "Vinix headless X server with a virtual framebuffer", + #:arch, [#:x86-64, #:aarch64], + #:license, "MIT", + #:url, "https://www.x.org/", + #:depends, ["musl", "libbsd", "libmd", "libxau", "libxdmcp", "libxfont2", "libxshmfence", "pixman", "xkbcomp", "xkeyboard-config", "font-misc-misc", "font-cursor-misc"], + #:makedepends, ["xorgproto", "xtrans", "linux-headers", "libx11", "libxcb", "libxext", "libxkbfile"], + #:source, ["https://xorg.freedesktop.org/archive/individual/xserver/xorg-server-21.1.16.tar.xz", + "https://raw.githubusercontent.com/vlang/vinix/c34a6707e1d8d3a23d0b1bfe6e6dbb16290e4f75/patches/xorg-server/jinx-working-patch.patch", + "configure.v"], + #:sha256sums, ["b14a116d2d805debc5b5b2aac505a279e69b217dae2fae2dfcb62400471a9970", + "74929113283893aff082d39edfa4a39f6e4f68134572831ce55ad75ebbc47449", + "9ac9cb2e6ae8e24833ba13c8cf6a34bfdf6ca49fa6e9f3bc16f2e876cbcbede5"], + #:prepare, fn() { + run("patch", "--batch", "--fuzz=0", "-d", "xorg-server-21.1.16", "-p1", "-i", "../jinx-working-patch.patch") + }, + #:build, fn() { + run("v", "run", "configure.v", "headless", "xorg-server-21.1.16", "headless") + run("make", "-C", "headless") + }, + #:check, fn() { + run("readelf", "-d", "headless/hw/vfb/Xvfb") + run("vinix-run", "headless/hw/vfb/Xvfb", "-help") + }, + #:package, fn() { + run("make", "-C", "headless/hw/vfb", "install", string-append("DESTDIR=", pkgdir())) + run("install", "-d", "-m755", string-append(pkgdir(), "/var/lib/xkb")) + run("install", "-Dm644", "xorg-server-21.1.16/COPYING", string-append(pkgdir(), "/usr/share/licenses/xvfb/COPYING")) + }) diff --git a/xvfb/configure.v b/xvfb/configure.v new file mode 120000 index 0000000..16d0f4c --- /dev/null +++ b/xvfb/configure.v @@ -0,0 +1 @@ +../xorg-server/configure.v \ No newline at end of file -- 2.56.1