mirror of
https://github.com/openai/codex.git
synced 2026-11-20 07:06:24 +00:00
Support sandboxed file streaming in exec-server (#38356)
## Why Streaming reads previously rejected requests that used a platform filesystem sandbox. ## What changed - Open streamed files in the sandbox helper and return the open file to the exec-server by passing a file descriptor on Unix or duplicating a file handle on Windows. - Advertise support through the `sandboxedFileStreaming` environment capability. - Preserve close-on-exec behavior for transferred descriptors, including the required inherited-descriptor cleanup on macOS. ## Testing - Cover bounded sandboxed streams, continued reads after path replacement, and rejection of symlink escapes outside readable roots. GitOrigin-RevId: 677b2444b74e834b78b87a8554bc119c1c6e08b2
This commit is contained in:
1 parent
fe614a6304
commit
c30a3e49c9
17 files changed
+487
-97
No files matched your search
@@ -75,6 +75,11 @@ pub(crate) async fn spawn_child_async(request: SpawnChildRequest<'_>) -> std::io
|
||||
if let Some(network) = network {
|
||||
network.apply_to_env(&mut env);
|
||||
}
|
||||
// macOS fd cleanup must keep the shell escalation socket.
|
||||
#[cfg(target_os = "macos")]
|
||||
let inherited_fd = env
|
||||
.get(codex_shell_escalation::ESCALATE_SOCKET_ENV_VAR)
|
||||
.and_then(|fd| fd.parse().ok());
|
||||
cmd.env_clear();
|
||||
cmd.envs(env);
|
||||
|
||||
@@ -103,6 +108,9 @@ pub(crate) async fn spawn_child_async(request: SpawnChildRequest<'_>) -> std::io
|
||||
// current parent dies."
|
||||
codex_utils_pty::process_group::set_parent_death_signal(parent_pid)?;
|
||||
}
|
||||
// macOS cannot receive the fd with close-on-exec set atomically.
|
||||
#[cfg(target_os = "macos")]
|
||||
codex_utils_pty::pty::close_inherited_fds_except(inherited_fd.as_slice());
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user