fix(sandbox): allow tty device in seatbelt profile#2524
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the macOS seatbelt sandbox base policy in crates/tui/src/sandbox/seatbelt.rs to allow read, write, and ioctl access to /dev/tty, which is required for TTY-mode shells to handle prompts (such as sshpass or sudo). It also adds a unit test to verify that the generated policy correctly includes this rule. There are no review comments, and I have no feedback to provide.
|
Harvested the scoped macOS seatbelt Local validation after the harvest:
I am keeping #2372 open because this is intentionally only the seatbelt policy slice. The broader controlling-terminal setup ( |
|
Thanks @cyq1017 — your contribution landed in
Closing this PR now that the code is on If you want to land more work and would prefer your future PRs merge cleanly without a harvest step, the |
Refs #2372
Problem:
/dev/ptmx//dev/ttysN, but not/dev/tty./dev/ttydirectly when running inside a TTY-backed shell task.Change:
/dev/ttyin the base seatbelt profile.Verification:
rustfmt crates/tui/src/sandbox/seatbelt.rs --edition 2024 --checkcargo test -p codewhale-tui --all-features --locked seatbelt::testsgit diff --checkNote:
Greptile Summary
Adds
/dev/tty(the controlling terminal device) to the macOS seatbelt sandbox base policy so tools likessh,sshpass, andsudocan open it for password/passphrase prompts when running inside a TTY-backed shell task.SEATBELT_BASE_POLICYgrantingfile-read*,file-write*, andfile-ioctlon the literal path/dev/tty, consistent with the already-allowed/dev/ptmxand/dev/ttys[0-9]+entries.Confidence Score: 5/5
Safe to merge — the change is a single-line policy addition with a matching test, and does not alter any logic paths.
The diff is two additions: one SBPL rule and one assertion-only test. The new /dev/tty rule is the natural complement to the already-present /dev/ptmx and /dev/ttys[0-9]+ allowances, so no policy surface is opened unexpectedly. The test is a straightforward string-contains check on the generated policy, which is sufficient given that the policy is a static constant — any future edit that removes the line will immediately break the test.
No files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[sandbox-exec invoked] --> B[SEATBELT_BASE_POLICY applied] B --> C{Device opened?} C -->|/dev/ptmx| D[Allowed: PTY master] C -->|/dev/ttysN| E[Allowed: PTY slave via regex] C -->|/dev/tty NEW| F[Allowed: controlling terminal] C -->|other /dev/*| G[Denied by default] F --> H[ssh / sshpass / sudo password prompt works]Reviews (1): Last reviewed commit: "fix(sandbox): allow tty device in seatbe..." | Re-trigger Greptile