Preserve custom arg0 for sandboxed exec-server processes (#34497)

## Why

Sandbox wrappers replaced the process launch command and did not carry an
`ExecParams.arg0` override through to the inner process.

## What changed

- Route sandboxed Unix launches with a custom `arg0` through a helper mode that
  re-execs the requested program with the override.
- Expose the helper executable to the filesystem sandbox and dispatch its mode
  from Codex and exec-server test binaries.

## Testing

Add coverage for the prepared sandbox command and an end-to-end remote process
that verifies both the custom `arg0` and filesystem restrictions.

GitOrigin-RevId: c9f8eef3906d184e670184c2eeed250d5895a9ca
This commit is contained in:
jif
2026-07-21 08:59:41 +00:00
committed by copyberry
parent 99eb575649
commit 4f1992732c
10 changed files with 243 additions and 14 deletions
+17 -1
View File
@@ -1,12 +1,28 @@
//! Minimal exec-server fixture for Bazel-only integration tests.
//!
//! Linking only exec-server avoids depending on the full Codex CLI binary
//! when a test only needs a WebSocket executor endpoint.
//! when a test only needs a WebSocket executor endpoint. It handles the arg0
//! helper mode because sandboxed process requests re-exec this binary.
use codex_exec_server::ExecServerRuntimePaths;
#[cfg(unix)]
use std::ffi::OsStr;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
#[cfg(unix)]
{
let mut args = std::env::args_os();
let _ = args.next();
if args.next().as_deref()
== Some(OsStr::new(
codex_exec_server::CODEX_ARG0_EXEC_HELPER_ARG1,
))
{
codex_exec_server::run_arg0_exec_helper_main();
}
}
let current_exe = std::env::current_exe()?;
let runtime_paths =
ExecServerRuntimePaths::new(current_exe, /*codex_linux_sandbox_exe*/ None)?;