Repository navigation
Backstop: call stat through a fixed path, so GNU stat on PATH cannot stop an install - #90
Conversation
…stop an install backstop.sh ran `stat -f %i` and `stat -f %z` by bare name, the only tools it still took from PATH. In a shell with GNU coreutils first on PATH (Homebrew's gnubin), GNU stat reads -f as --file-system and prints no inode or size. The fd 9 check then never matches the lock file, so the backstop that install.sh runs under its own recovery lock reopens the lock and waits on its caller until it exits 75. install.sh stops with "the backstop could not fully undo a previous session" on a Mac that never had one. uninstall.sh hands its lock down the same way. The LaunchAgent is not affected: launchd gives it the system PATH. Add STAT=/usr/bin/stat to the fixed tool paths and use it for both calls. The regression test hands the lock down on fd 9 with a GNU-style stat stub first on PATH; on the old script it exits 75 and the stub runs. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Brings in krishhgg#86's TestScripts.write, which the next commit uses for this PR's test scripts, and the other merges since bb5cf2b. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This branch started before krishhgg#86, so the new test wrote both scripts directly and CI's ShellCheck step never saw them. They now go through TestScripts.write like the sibling hand-down test's wrapper. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
I pushed two commits to this branch:
The backstop change itself had no findings. 🤖 Generated with Claude Code |
|
Thanks again for this fix. Before it ships in a release, I need test evidence from your Mac for the code as it is now on Checks for this change (on your macOS 27 MacBook Pro)Test Run checks 1 to 3 in a Terminal with GNU coreutils first on PATH:
Build and what to post
Post the results as a comment on this PR. Put long logs in a gist and link it. Run everything while you're with the Mac, on a stable, ventilated surface, never in a bag, and not while you have unsaved work open. 🤖 Generated with Claude Code |
What happened
On a Mac with Homebrew's coreutils first on PATH, a source install stopped before installing anything. That PATH resolved
statto/opt/homebrew/opt/coreutils/libexec/gnubin/stat(GNU coreutils 9.12):The Mac had never run Insomnia. insomnia.log had one line:
backstop.sh decides whether its fd 9 is the caller's handle on the lock with
stat -f %i, andstatwas the only tool it still took from PATH. GNU stat reads-fas--file-system, so both sides print file system text instead of an inode, and the two never match.LOCK_TIMEOUT_SECONDS, then exits 75.statreads the size of the app binary's--resume-frozenanswer with-f %z.What changes
STAT=/usr/bin/statjoins the fixed tool paths, and both calls use it. A comment says why.testBackstopSharesLockHandedDownOnFd9WithGNUStatFirstOnPathrepeats the existing hand-down test with a GNU-stylestatstub first on PATH. The stub logs and prints what GNU prints.testBackstopSharesLockHandedDownOnFd9andtestBackstopWithUnrelatedFd9DoesNotShareAForeignLock.Checks
swift teston this branch: 1,224 tests, 0 failures, 0 skipped (tmux installed), the new test included.swift build -c release -Xswiftc -warnings-as-errorspasses./bin/bash -nand the bash 4 grep on every script, and ShellCheck 0.11.0, pass../scripts/install.shfrom the same Terminal finished, and logged "LaunchAgent com.insomnia.backstop loaded (launchctl print confirms)".Sources
-fis--file-system: "Report information about the file systems where the given files are located instead of information about the files themselves." GNU Coreutils, stat invocation-f format, "Display information using the specified format", withithe inode number andzthe size in bytes: FreeBSD stat(1). macOS'sman 1 statsays the same.scripts-call-tools-through-fixed-path-variables🤖 Generated with Claude Code

Confidence Score: 5/5
This PR appears safe to merge; no actionable issue remains.Summary
The backstop now calls
/usr/bin/statthroughSTAT, so a GNUstatearlier onPATHcannot disrupt recovery.statis first onPATH.Reviews (2) · Last reviewed commit: "Tests: write the GNU stat stub and its w..." · Reviewed by Greptile