fix(install): atomic mv to a fresh inode (real fix for macOS SIGKILL)#25
Merged
Conversation
The earlier xattr-c change was NOT the actual root cause. Investigation on a poisoned install: inode=8641475 (curl -o overwriting in place) → exit 137 every time inode=8757579 (rm + fresh download, new inode) → runs fine System log on the kill: proc 7939: load code signature error 2 for file "vibecockpit" (AppleSystemPolicy) ASP: Security policy would not allow process macOS' syspolicyd tracks Gatekeeper trust *per inode*. When curl -o (or wget -O) overwrites an existing file in place, the inode is preserved and any prior "blocked" verdict for that inode sticks even after the bytes are replaced — so the new binary fails to load with EBADEXEC at the kernel level despite `codesign --verify` reporting it as valid. Fix: download() now writes to a sibling temp file (mktemp in $bin_dir) and `mv -f` over the destination. mv on the same filesystem is a rename(2): atomic, fresh inode, no inherited verdict. Bonus: if the download fails the existing binary at $dest is untouched (curl -o would have already truncated it). Verified locally: poisoned inode SIGKILL'd; new install.sh produced a fresh inode and the binary launched cleanly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was actually wrong
The earlier `xattr -d → xattr -c` change in PR #24 wasn't the real root cause — local repro showed xattrs were already empty. The actual issue:
System log on the kill:
```
proc 7939: load code signature error 2 for file "vibecockpit"
(AppleSystemPolicy) ASP: Security policy would not allow process
```
macOS' `syspolicyd` tracks Gatekeeper trust per inode. When `curl -o` overwrites an existing file in place, the inode is preserved and any prior "blocked" verdict for that inode sticks even after the bytes are replaced — so the new binary fails to load with EBADEXEC at the kernel level despite `codesign --verify` reporting it as valid.
Fix
`download()` now writes to a sibling temp file (`mktemp` in `$bin_dir`) then `mv -f` over the destination. `mv` on the same filesystem is a `rename(2)` — atomic, fresh inode, no inherited verdict.
Two bonuses:
Test plan