Files
reims-vgpu/guest/bundle/tests/bundle_files_check.sh
T
Anees Iqbal aea974e518 🐛 Write no file from the bundle, logging to os_log instead
Every process that loads the bundle wrote /tmp/rgfx-diag.log (a trace left
from bring-up, at device init and on transport failures) and
/tmp/rgfx-surface-copies.log (the surface copy counts, every 10 s while
copies run). In sandboxed processes each write is refused and reported, and
the reports fill the kernel's message buffer: wire-v3-p1 saw them from
iconservicesagent, VTDecoderXPCService, WallpaperAerialsExtension and
avconferenced. The trace's NSLog lines also went to every app's stderr.

The transport's failures (the user client, the caps blob, the context, the
completion thread and its wait) are os_log errors now, and the copy counts
an os_log info line; the trace's other lines, +load and the -init override
that only logged, go. make test runs tests/bundle_files_check.sh, which fails
where the bundle's executable names a temporary directory or imports open(2)'s
family; it failed on the bundle before this change.
2026-11-05 21:59:24 -08:00

23 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# bundle_files_check.sh BUNDLE: that the bundle writes no file of its own. Every Metal process
# loads it, sandboxed ones too, where a write outside the process's own paths is refused and
# reported to the kernel's log: so the bundle's executable names no temporary directory and
# imports none of open(2)'s family. What it writes is the app's own, through Foundation (a binary
# archive at the app's URL); what it reports goes to os_log. Part of `make test`.
set -euo pipefail
exe=$1
[ -f "$exe" ] || exe=$1/Contents/MacOS/reims-graphics
fails=0
paths=$(strings -a "$exe" | grep -E '(^|[^[:alnum:]])/(private/)?(var/)?tmp(/|$)' || true)
if [ -n "$paths" ]; then
echo "bundle_files_check: FAIL: a temporary path in $exe: $paths"
fails=1
fi
calls=$(nm -u "$exe" | grep -E '^_(open|openat|open_dprotected_np|fopen|freopen|creat|mkstemp|mkstemps|mkdtemp|tmpfile)(\$.*)?$' || true)
if [ -n "$calls" ]; then
echo "bundle_files_check: FAIL: $exe imports" $calls
fails=1
fi
[ $fails = 0 ] || exit 1
echo "bundle_files_check: no temporary path, no open(2) family in $exe"