Repository navigation
fix(cli): publish a readable /usr/local/bin/orca symlink on macOS and repair unreadable ones - #29245
Conversation
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
056663ef-fbea-4170-957b-0043169f6b92
📥 Commits
Reviewing files that changed from the base of the PR and between 26f0581 and d9ed3719b58be2a1053090909607758028aab49b.
📒 Files selected for processing: 4
src/main/cli/cli-command-filesystem-transaction.tssrc/main/cli/cli-command-inspection.tssrc/main/cli/cli-command-installation.tssrc/main/cli/cli-command-privileged-transaction.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
|
Thanks for picking this up so fast. I reviewed it and ran it on a second Mac. The core fix is right. I'd like one small round of changes before merge. What I verified
Also checked: a readable link to an older Requested changes1. Use one ownership rule, not two. For an unreadable link, the root script decides "is this Orca's?" with its own pattern,
The packaged case ( [ -L "$cmd" ] && [ "$(stat -f '%d:%i' "$cmd")" = "<dev:ino>" ] && chmod -h 755 "$cmd"Then re-inspect and continue through the normal path with the normal 2. Explain the refusal. When root refuses an unreadable foreign link, the script restores it and exits 73 with empty stderr, so the user sees a generic 3. Optional, same root cause, not new in this PR. Testing note: if you keep a root-side ownership check, one small table test comparing it against |
… repair unreadable ones The privileged install script ran under umask 077, and macOS applies the umask to symlinks too, so the root-owned command was 0700. macOS also enforces a symlink's own mode on readlink, so Settings threw EACCES and the launcher could not resolve the app bundle. The script now runs under umask 022 and creates only its transaction directories private, which also fixes parent directories it creates. An existing link the user cannot read reports as stale; registering again asks root to make it readable, then the normal ownership check decides what happens to it.
d9ed371 to
27f9002
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
2ac0e276-f3e2-41b0-84c2-320cd226b4a5
📥 Commits
Reviewing files that changed from the base of the PR and between d9ed3719b58be2a1053090909607758028aab49b and 27f9002.
📒 Files selected for processing: 3
src/main/cli/cli-command-filesystem-transaction.tssrc/main/cli/cli-command-installation.tssrc/main/cli/cli-command-privileged-transaction.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
brennanb2025
left a comment
There was a problem hiding this comment.
Thanks Kelvin, this round addresses all three points:
- One ownership rule. For an unreadable link, the admin step now only makes the link readable, after checking it's still the same link. The normal
isManagedSymlinkTargetcheck then decides, so there's no second pattern to drift. A link to the current launcher takes one prompt, an older Orca launcher is replaced after a second prompt, and a foreign link is refused with the existing "Refusing to replace non-Orca command" message. - Refusal message. It's covered by the above; the unexplained exit-73 path for foreign links is gone.
- Permissions. The script runs under
umask 022, and only the transaction and publish directories usemkdir -m 700, so new parent directories and the link both come out readable.
I also confirmed the new admin prompt only appears on register and remove, never when Settings reads the status. I reviewed this version by reading the diff. The earlier real-app and macOS test runs were on the previous head, and I haven't run the new tests myself.
One optional follow-up, not blocking: the make-readable step checks [ -L ] and the device and inode, then runs chmod -h 755 on the live path as root. If something swapped a regular file into that path between the check and the chmod, root would change that file's mode. That needs a writable command directory and a very narrow race during the password prompt, so I'm fine landing as is. Doing the chmod on the entry after moving it into the private transaction directory, as the install path already does, would close it.


ELI5
Registering the
orcacommand on a Mac through the admin password prompt left behind a link that only root could read. Your own account could not see where it pointed, so Settings showed an error and typingorcain a terminal failed. The link is now created so everyone can read it, and an old unreadable link can be repaired from Settings.What Changed
Before: after registering the CLI with the admin prompt,
/usr/local/bin/orcawas root-owned with mode0700. Opening Settings failed withEACCES: permission denied, readlink '/usr/local/bin/orca', and runningorcaprintedUnable to determine Orca.app path from symlink. Registering again failed with the same error, so the only way out was a manualsudo chmod -h 755.After: a fresh registration publishes the link as
0755, so Settings loads andorcaresolves the app. A link left behind by an older version shows as stale in Settings with "cannot be read. Register again to repair it". Clicking register asks for the admin password once, root makes the link readable, and Orca then judges it by its normal ownership rule. If it already points at the current launcher, which is the case for everyone hit by #19120, that is the end. If it points at an older Orca launcher, the usual replacement follows. If it points somewhere else, Orca refuses with its usual "non-Orca command" message and leaves it in place.Mechanism: the privileged shell transaction ran entirely under
umask 077so its staging directories would be private. On macOS that umask also applies toln -s, so the published link inherited0700, and macOS enforces a symlink's own mode onreadlink. Three changes insrc/main/cli/:cli-command-filesystem-transaction.ts: the script now runs underumask 022and creates only its transaction and publish directories withmkdir -m 700. That gives the link0755and also fixes any parent directories the script creates for a custom command path, which used to come out root-only. A new one-line privileged command,buildMacPrivilegedSymlinkReadableCommand, runschmod -h 755on the link after checking its device and inode still match the inspected entry. It deletes and replaces nothing. The transaction builder takes the inspection object instead of three copied fields.cli-command-inspection.ts: a permission error fromreadlinkreports the link as stale with a null target instead of throwing. The Settings pane already hides the target line when it is null, and nothing auto-installs on stale.cli-command-installation.ts:inspectStableSymlinkruns the make-readable command when the link is unreadable on macOS, then re-inspects. From there install and remove continue through the existing path and the existingisManagedSymlinkTargetcheck. The stable-inspection loop no longer treats an unreadable link as "changed under us".Why
The link's mode comes from the umask of the process that creates it, so fixing the umask fixes the cause in one step. Alternatives considered:
chmod -h 755afterln -s: a second step that can fail separately, and the staged link would still be created wrong first.umask 077and scoping022aroundln -sonly: fixes the link but leaves parent directories created bymkdir -proot-only. Setting022for the script and making the private directories explicit covers both.Linked Issue
Fixes #19120
Visual Proof
N/A. No layout change. The CLI status row shows the existing stale state instead of an error, and the
orcacommand works. Brennan's before and after captures from a dev build are in the review thread below.Testing
Tested on macOS (arm64). Reproduced first by running the real generated transaction script in a temp directory: the link came out
0700, and removing the read bit madereadlinkfail with EACCES.Five assertions added to
cli-command-privileged-transaction.test.ts, which runs the real shell commands as a non-root user withlchmodstanding in for root ownership:07550755chmod -h 755makes it installedAll five fail on the unmodified code.
pnpm lint,pnpm tc, the three CI audits,check:code-quality:changed,check:react-doctor:changedandcheck:zustand-selector-fanoutpass on the branch rebased onto current main. The wholesrc/main/clisuite passes apart frompackaged-cli-assets.test.ts, which fails on main too on this machine because of a/varversus/private/vartmpdir mismatch.Review
Agent skill upstream boundary
Notes
Security: the transaction and quarantine directories stay
0700; the published link and any created parent directories are0755, like the other shims in/usr/local/bin. Root never deletes or replaces an unreadable link; it only makes it readable, after an inode check, and the existing ownership rule decides the rest. Cross-platform: macOS only. Linux ignores symlink modes, and Windows uses wrapper files. SSH, mobile, remote wire and performance are unaffected. Backwards compatible: readable installs behave exactly as before.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)