| 1 | #!/bin/sh |
| 2 | set -eu |
| 3 | export PATH=/bin:/usr/bin:/sbin:/usr/sbin HOME=/tmp |
| 4 | export DISPLAY=:71 XAUTHORITY=/tmp/vinix-x11.Xauthority |
| 5 | server= |
| 6 | finish() { |
| 7 | status=$? |
| 8 | if [ "$status" -ne 0 ]; then |
| 9 | echo 'Vinix headless X11 guest check failed' |
| 10 | if [ -f /tmp/xvfb.log ]; then cat /tmp/xvfb.log; fi |
| 11 | fi |
| 12 | if [ -n "$server" ]; then kill "$server" 2>/dev/null || true; fi |
| 13 | /sbin/poweroff -f |
| 14 | } |
| 15 | trap finish EXIT |
| 16 | mkdir -p /tmp |
| 17 | # This fixed cookie belongs to an isolated guest display with TCP disabled. |
| 18 | xauth -q -f "$XAUTHORITY" add "$DISPLAY" MIT-MAGIC-COOKIE-1 0123456789abcdef0123456789abcdef |
| 19 | Xvfb "$DISPLAY" -auth "$XAUTHORITY" -nolisten tcp -noreset -screen 0 128x128x24 >/tmp/xvfb.log 2>&1 & |
| 20 | server=$! |
| 21 | attempt=0 |
| 22 | until xset q >/tmp/xset.log 2>&1; do |
| 23 | kill -0 "$server" |
| 24 | attempt=$((attempt + 1)) |
| 25 | [ "$attempt" -lt 20 ] |
| 26 | sleep 1 |
| 27 | done |
| 28 | /x11-client --display |
| 29 | printf 'Vinix.sidecar: tested\n' >/tmp/xresources |
| 30 | xrdb -nocpp -load /tmp/xresources |
| 31 | xrdb -query >/tmp/xresources-query |
| 32 | grep -E '^Vinix\.sidecar:[[:space:]]*tested$' /tmp/xresources-query |
| 33 | : >/tmp/empty.Xauthority |
| 34 | if XAUTHORITY=/tmp/empty.Xauthority xset q >/tmp/unauthorized.log 2>&1; then |
| 35 | echo 'Xvfb accepted an unauthenticated client' |
| 36 | exit 1 |
| 37 | fi |
| 38 | echo 'Packaged Xvfb, Xauth, Xlib, xset and xrdb guest checks passed.' |
| 39 | echo 'VPAC FIXTURE GUEST PASS' |
| 40 | |