Preserve native sandbox executable paths and PTY dispatch names (#61910)

## Why

Sandbox helpers with non-UTF-8 paths can lose their exact executable path when converted into command requests. PTY launches with a custom `argv[0]` can also try to execute the dispatch name instead of the configured program.

## What changed

- Carry native executable paths through sandbox requests, local execution, shell snapshots, and sandbox integrity checks.
- Use native Unix PTY spawning when `argv[0]` differs from the executable, preserving the dispatch name and controlling terminal setup.
- Preserve PTY executable lookup through the child environment's `PATH` and fallback to its home directory when the requested working directory is missing.

## Testing

Add regression coverage for non-UTF-8 sandbox helper paths, PTY dispatch names, child `HOME`/`PATH` lookup, controlling terminals, and exit-code preservation.

GitOrigin-RevId: 6a2af0486220d98195f5d67fde2597e3c4515e11
This commit is contained in:
viyatb-oai
2026-11-16 23:26:42 +00:00
committed by copyberry
parent cff061fca9
commit c9df641eac
30 changed files with 346 additions and 108 deletions
+4
View File
@@ -287,6 +287,7 @@ async fn exec_full_buffer_capture_ignores_expiration() -> Result<()> {
justification: None,
arg0: None,
},
/*native_program*/ None,
NetworkSandboxPolicy::Enabled,
/*stdout_stream*/ None,
/*after_spawn*/ None,
@@ -323,6 +324,7 @@ async fn exec_full_buffer_capture_keeps_io_drain_timeout_when_descendant_holds_p
justification: None,
arg0: None,
},
/*native_program*/ None,
NetworkSandboxPolicy::Enabled,
/*stdout_stream*/ None,
/*after_spawn*/ None,
@@ -1311,6 +1313,7 @@ fn command_runs_after_integrity_check_failure(time_out: bool) -> anyhow::Result<
// This boundary receives prepared argv. Exercise a real child without requiring
// a native sandbox installation to test the checker's failure isolation.
let request = SandboxExecRequest {
native_program: None,
command: if cfg!(windows) {
vec![
"cmd.exe".into(),
@@ -1429,6 +1432,7 @@ async fn kill_child_process_group_kills_grandchildren_on_timeout() -> Result<()>
let output = exec(
params,
/*native_program*/ None,
NetworkSandboxPolicy::Restricted,
/*stdout_stream*/ None,
/*after_spawn*/ None,