[Seatbelt] If the requested cwd is not allowed by policy, start the process from a sandbox-allowed fallback directory
Relevant area(s)
macOS
Brief description of your issue
When a sandboxed command is launched on macOS Seatbelt with a process working directory that is not allowed by the sandbox policy, the child shell can print noisy getcwd warnings during startup.
The command itself may still succeed, especially when it uses an absolute path that is allowed by the policy. The issue is confusing stderr noise, not a command failure .
Example
Command:
cat /Users/tester/Downloads/coding-agent-test/ro/protected.txt
Output:
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted
original read-only content
The file read succeeds, but the startup warnings make the result look like something failed.
Related code:
https://github.com/microsoft/mxc/blob/main/src/backends/seatbelt/common/src/seatbelt_runner.rs#L164-L170
Expected Behavior
mxc should avoid or reduce noisy getcwd startup warnings when the requested process working directory is not allowed by the sandbox policy.
Possible approaches:
- If the requested working directory is not allowed by policy, start the process from a sandbox-allowed fallback directory.
- Or provide a way for callers to distinguish the logical/session cwd from the process launch cwd.
Steps to reproduce
As above
Expected behavior
As above
Actual behavior
As above
Triage summary
- Labels applied:
Area-Executor-Schema(Seatbelt backend executor — working directory handling inseatbelt_runner.rs) - Existing labels kept:
OS-MacOS,Issue-Bug(already present and correct) - Assigned to:
@richiemsft(macOS / Seatbelt area owner) - Needs-Triage: removed
Generated by 🏷️ Issue Triage for #611 · 16 AIC · ⌖ 5.58 AIC · ⊞ 6.3K · ◷
This mainly stems from a misconfiguration issue, and a lot of the noise-related concerns were addressed in prior PRs. Approach A sounds like a viable feature request.
This will remain a configuration issue. No plans to implement a fallback directory.