Address exec-server sandbox review comments

- preserve sandbox child environment variables from shared launch requests
- dispatch codex-exec-server through codex-arg0 so helper arg0 is executable
- send sandbox preference to remote servers and report the server-selected sandbox

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
starr-openai
2026-04-08 10:53:18 -07:00
parent 5824352d53
commit a69385f63f
23 changed files with 140 additions and 110 deletions

View File

@@ -98,22 +98,20 @@ struct LocalExecProcess {
}
#[derive(Clone, Debug, Default)]
struct ExecServerRuntimeConfig {
pub struct ExecServerRuntimeConfig {
codex_linux_sandbox_exe: Option<PathBuf>,
}
impl ExecServerRuntimeConfig {
fn detect() -> Self {
pub fn new(codex_linux_sandbox_exe: Option<PathBuf>) -> Self {
Self {
// The Codex CLI and codex-exec-server both dispatch the Linux
// sandbox helper from their own executable via argv[0].
codex_linux_sandbox_exe: if cfg!(target_os = "linux") {
std::env::current_exe().ok()
} else {
None
},
codex_linux_sandbox_exe,
}
}
pub fn detect() -> Self {
Self::default()
}
}
struct StartedProcess {
@@ -133,13 +131,20 @@ impl Default for LocalProcess {
impl LocalProcess {
pub(crate) fn new(notifications: RpcNotificationSender) -> Self {
Self::new_with_runtime(notifications, ExecServerRuntimeConfig::detect())
}
pub(crate) fn new_with_runtime(
notifications: RpcNotificationSender,
runtime: ExecServerRuntimeConfig,
) -> Self {
Self {
inner: Arc::new(Inner {
notifications,
processes: Mutex::new(HashMap::new()),
initialize_requested: AtomicBool::new(false),
initialized: AtomicBool::new(false),
runtime: ExecServerRuntimeConfig::detect(),
runtime,
}),
}
}
@@ -306,6 +311,7 @@ impl LocalProcess {
.await
.map(|started| ExecResponse {
process_id: started.process_id,
sandbox: started.sandbox_type,
})
}
@@ -523,7 +529,7 @@ fn prepare_exec_launch(
&params.env,
params.sandbox.additional_permissions.clone(),
)?;
params
let mut launch = params
.sandbox
.transform(
command,
@@ -533,7 +539,9 @@ fn prepare_exec_launch(
None,
runtime.codex_linux_sandbox_exe.as_ref(),
)
.map_err(|err| internal_error(format!("failed to build sandbox launch: {err}")))
.map_err(|err| internal_error(format!("failed to build sandbox launch: {err}")))?;
launch.prepare_env_for_spawn();
Ok(launch)
}
impl LocalProcess {