Skip to content

fix(ssh): give Macs sharing a home their own server, and make the shared-home claim exclusive - #29284

Merged
nwparker merged 1 commit into
mainfrom
nwparker/ssh-shared-home-hostid
Oct 16, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/ssh-shared-home-hostid

Conversation

@nwparker

@nwparker nwparker commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​160 $\color{#cf222e}{\Huge{\mathbf{−}}}$​13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​147
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​49 $\color{#cf222e}{\Huge{\mathbf{−}}}$​24 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​25

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 read IOPlatformUUID from ioreg -rd1 -c IOPlatformExpertDevice, which is what managed-hook-owner-identity.ts already 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 run mv, and each read back its own key. Both then used the same installation, PID files and data. After: ln is still the fast path. When ln can't decide, each computer renames a directory that already holds its claim into orcad-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

  • Why not a mkdir lock: a lock taken with mkdir has 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.
  • Why not a symlink: old clients read the claim with [ -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:

  • Old client, new host: the old client still sees no Mac identity and stays on the login home, as it does today.
  • New client, old host: older orcads on macOS recorded owners with no machine identity. On macOS those owners aren't treated as foreign, so the first new client to connect claims the login home and keeps the server already running there (tested).
  • Existing state: no Mac ever got a key, claim or machine home under the empty ID, so nothing needs migrating.
  • Host descriptors: a macOS host descriptor now includes a machineBinding. A pin with no binding that receives one, and a pin with a binding that loses one, both stay pinned, not moved (tested).
  • Profile-state ownership: an old record with no machine identity, or a reader with none, still falls through to the PID and boot checks, as before.

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.ts runs the real probe and claim commands in a shell against a shared temp home, with fake ioreg, uname, ln and mv per machine. The fake sysctl fails the way macOS does. New tests: two machines on a filesystem without hard links, and two machines replacing an empty claim. In both, a fake mv lines 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, dash and ksh. I also ran the claim command by hand under busybox sh (Alpine) with and without hard links.

  • I checked the probe on a real Mac: it returns the real IOPlatformUUID.

  • profile-state-access-identity.test.ts covers the ioreg read, its caching, and rejection of failed, zero and malformed output. runtime-host-pairing-identity.test.ts covers the binding transitions.

  • pnpm tc:node and pnpm run check:code-quality:changed pass.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

The shell stays POSIX sh, and ioreg is tried bare first, then at /usr/sbin/ioreg. Windows and WSL hosts are unchanged; they never probe or claim.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…shared-home claim exclusive without hard links (#29259)
@coderabbitai

coderabbitai Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0c4b0437-1cec-4118-b599-340f64593787
📥 Commits

Reviewing files that changed from the base of the PR and between ef98eff and 607781a.

📒 Files selected for processing: 5
  • src/main/persistence/profile-state/profile-state-access-identity.test.ts
  • src/main/persistence/profile-state/profile-state-access-identity.ts
  • src/main/ssh/orcad-machine-home.test.ts
  • src/main/ssh/orcad-machine-home.ts
  • src/shared/runtime-host-pairing-identity.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 9c863a6 into main Oct 16, 2026
48 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

orcad machine homes: no macOS machine identity, and the fallback claim can be won twice (follow-up to #29214)

1 participant