Repository navigation
fix(ssh): give Macs sharing a home their own server, and make the shared-home claim exclusive - #29284
Merged
Merged
Conversation
…shared-home claim exclusive without hard links (#29259)
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 6 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
9 tasks done
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.
ELI5
When several computers share one home folder, Orca gives each computer its own copy of the remote server. Two gaps stopped that from working: Macs never figured out which computer they were, and on some network drives two computers could both think they owned the shared folder. This fixes both.
What Changed
1. macOS machine identity. Before: Orca read the Mac's hardware ID with
sysctl -n kern.hostuuid, but that setting doesn't exist on macOS, so every Mac got an empty ID. Mac SSH hosts never got their own server, and Orca's local profile-state code also had no machine ID on any Mac. After: both places readIOPlatformUUIDfromioreg -rd1 -c IOPlatformExpertDevice, which is whatmanaged-hook-owner-identity.tsalready uses. One shared parser (parseDarwinPlatformUuid) lowercases and validates the value, so the SSH probe and the owner records it compares against always agree.2. Exclusive claim without hard links. Before: the first computer claimed the shared home with
ln partial claim || [ -s claim ] || mv -f partial claim. If the filesystem had no hard links, or an empty claim file was left over, two computers could both get past the size check, both runmv, and each read back its own key. Both then used the same installation, PID files and data. After:lnis still the fast path. Whenlncan't decide, each computer renames a directory that already holds its claim intoorcad-machine.arbiter. A directory rename is atomic and only one can succeed. A computer that loses ends up with its directory nested inside the winner's and removes it. Every computer then writes the arbiter's claim, never its own, so concurrent writers agree. An empty or missing claim is filled from the arbiter once one exists.Why
mkdirhas to be released, and a dropped SSH session can leave it held forever. Then we'd need stale-lock detection, which is racy in its own right. The arbiter is never released, and it shows up already holding the winner's claim, so a crash at any step leaves nothing half-done.[ -f ]and treat anything else as unreadable, which makes them throw. The claim file keeps its exact format, and the arbiter sits next to it, where old clients never look.Mixed versions:
machineBinding. A pin with no binding that receives one, and a pin with a binding that loses one, both staypinned, notmoved(tested).Linked Issue
Fixes #29259
Visual Proof
N/A: no UI change; this only affects which folder an SSH host's managed server runs from.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
src/main/ssh/orcad-machine-home.test.tsruns the real probe and claim commands in a shell against a shared temp home, with fakeioreg,uname,lnandmvper machine. The fakesysctlfails the way macOS does. New tests: two machines on a filesystem without hard links, and two machines replacing an empty claim. In both, a fakemvlines up their claim writes so the old race happens every time. Also new: a claim emptied later is restored from the arbiter, and a Mac whose orcad recorded no machine identity keeps its running install. Against the old claim command, the 3 claim tests fail. Against the old identity code, 11 tests fail.The suite passes under
/bin/sh,dashandksh. I also ran the claim command by hand under busyboxsh(Alpine) with and without hard links.I checked the probe on a real Mac: it returns the real
IOPlatformUUID.profile-state-access-identity.test.tscovers the ioreg read, its caching, and rejection of failed, zero and malformed output.runtime-host-pairing-identity.test.tscovers the binding transitions.pnpm tc:nodeandpnpm run check:code-quality:changedpass.Review
Agent skill upstream boundary
Notes
The shell stays POSIX
sh, andioregis tried bare first, then at/usr/sbin/ioreg. Windows and WSL hosts are unchanged; they never probe or claim.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)