mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 12:47:47 +01:00
All three were found by review and reproduced before fixing. Each let a run
report success while proving nothing -- the shape this harness exists to
prevent.
A reused prefix defeated dropped-write detection entirely. Run 1's files were
still there when run 2's manifest was taken, so the manifest reported writes
that never happened and the fixture pair diffed CLEAN. The doc's own examples
demonstrated that workflow. A non-empty prefix is now refused -- not deleted,
since the path is user-supplied -- and the examples use distinct prefixes.
A missing bwrap was swallowed. trace_prefix_bwrap_argv returned 1, but the
caller reads it through `mapfile < <(...)` and a process substitution's status
is discarded, so runner ended up empty and the run continued with no sandbox
and no uid 0. Same swallow as the grep-status one fixed earlier, one layer up.
bwrap is now probed in validate_requirements, before anything runs.
The absolute-path scan only fired when no --bind-abs was given at all, so
binding one path and missing three produced no warning. It now runs whenever
--prefix is given and reports only what is not already covered. Fixing that
surfaced a second defect: --bind-abs on a FILE aborted with "Can't mkdir
/etc/profile: Not a directory", and binding its parent reintroduced the
wholesale /etc shadowing this change had already measured as harmful ($SUDO_USER
collapsing to /home//, the real /etc/profile unreadable). Files are now bound
file-over-file, seeded with a copy so a script that greps before appending sees
real content.
Also measured rather than argued: the XDG redirect. A new fixture run with a
real XDG_DATA_HOME pointing at a decoy shows all four writes landing in the
prefix and the decoy empty -- the rsync --delete data-loss path, proven closed
without running install_leechblock.sh. And no-prefix output was diffed against
cdf2a55 from a detached worktree: byte-identical, so existing baselines hold.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
31 lines
1.3 KiB
Bash
Executable File
31 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Fixture: writes addressed through XDG_* rather than through $HOME.
|
|
#
|
|
# --prefix exports XDG_DATA_HOME, XDG_CONFIG_HOME, XDG_CACHE_HOME and
|
|
# XDG_STATE_HOME explicitly instead of letting them default off HOME. This
|
|
# fixture is what makes that claim measurable: all four writes must appear in
|
|
# the manifest under the prefix.
|
|
#
|
|
# Why it matters beyond tidiness: install_leechblock.sh reads XDG_DATA_HOME
|
|
# directly and then runs `rsync -a --delete` at the result. If the harness
|
|
# redirected only HOME, a real XDG_DATA_HOME inherited from the caller's
|
|
# environment would still point at live data -- and --delete would empty it.
|
|
# Proving the redirect here costs nothing; proving it by running the installer
|
|
# would risk exactly the loss being guarded against.
|
|
|
|
set -euo pipefail
|
|
|
|
data_dir="${XDG_DATA_HOME:-$HOME/.local/share}/xdg-fixture"
|
|
config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/xdg-fixture"
|
|
cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/xdg-fixture"
|
|
state_dir="${XDG_STATE_HOME:-$HOME/.local/state}/xdg-fixture"
|
|
mkdir -p "$data_dir" "$config_dir" "$cache_dir" "$state_dir"
|
|
|
|
printf 'data\n' >"$data_dir/payload"
|
|
printf 'config\n' >"$config_dir/settings.conf"
|
|
printf 'cache\n' >"$cache_dir/entry"
|
|
printf 'state\n' >"$state_dir/last-run"
|
|
|
|
echo "wrote four XDG-addressed files"
|