Simplify exec-server runtime paths

Route Linux filesystem sandboxing through the configured Codex executable instead of carrying a separate linux-sandbox helper path through ExecServerRuntimePaths.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
starr-openai
2026-04-15 13:38:54 -07:00
parent ab715021e6
commit e5e2aca735
14 changed files with 31 additions and 106 deletions

View File

@@ -45,14 +45,12 @@ impl Drop for ExecServerHarness {
pub(crate) struct TestCodexHelperPaths {
pub(crate) codex_exe: PathBuf,
pub(crate) codex_linux_sandbox_exe: Option<PathBuf>,
}
pub(crate) fn test_codex_helper_paths() -> anyhow::Result<TestCodexHelperPaths> {
let (helper_binary, codex_linux_sandbox_exe) = super::current_test_binary_helper_paths()?;
let helper_binary = super::current_test_binary_helper_path()?;
Ok(TestCodexHelperPaths {
codex_exe: helper_binary,
codex_linux_sandbox_exe,
})
}

View File

@@ -22,24 +22,15 @@ pub static TEST_BINARY_DISPATCH_GUARD: Option<TestBinaryDispatchGuard> = {
}
TestBinaryDispatchMode::InstallAliases
});
maybe_run_exec_server_from_test_binary(guard.as_ref());
maybe_run_exec_server_from_test_binary();
guard
};
pub(crate) fn current_test_binary_helper_paths() -> anyhow::Result<(PathBuf, Option<PathBuf>)> {
let current_exe = env::current_exe()?;
let codex_linux_sandbox_exe = if cfg!(target_os = "linux") {
TEST_BINARY_DISPATCH_GUARD
.as_ref()
.and_then(|guard| guard.paths().codex_linux_sandbox_exe.clone())
.or_else(|| Some(current_exe.clone()))
} else {
None
};
Ok((current_exe, codex_linux_sandbox_exe))
pub(crate) fn current_test_binary_helper_path() -> anyhow::Result<PathBuf> {
Ok(env::current_exe()?)
}
fn maybe_run_exec_server_from_test_binary(guard: Option<&TestBinaryDispatchGuard>) {
fn maybe_run_exec_server_from_test_binary() {
let mut args = env::args();
let _program = args.next();
let Some(command) = args.next() else {
@@ -73,10 +64,7 @@ fn maybe_run_exec_server_from_test_binary(guard: Option<&TestBinaryDispatchGuard
std::process::exit(1);
}
};
let runtime_paths = match ExecServerRuntimePaths::new(
current_exe.clone(),
linux_sandbox_exe(guard, &current_exe),
) {
let runtime_paths = match ExecServerRuntimePaths::new(current_exe.clone()) {
Ok(runtime_paths) => runtime_paths,
Err(error) => {
eprintln!("failed to configure exec-server runtime paths: {error}");
@@ -103,21 +91,3 @@ fn maybe_run_exec_server_from_test_binary(guard: Option<&TestBinaryDispatchGuard
};
std::process::exit(exit_code);
}
fn linux_sandbox_exe(
guard: Option<&TestBinaryDispatchGuard>,
current_exe: &std::path::Path,
) -> Option<PathBuf> {
#[cfg(target_os = "linux")]
{
guard
.and_then(|guard| guard.paths().codex_linux_sandbox_exe.clone())
.or_else(|| Some(current_exe.to_path_buf()))
}
#[cfg(not(target_os = "linux"))]
{
let _ = guard;
let _ = current_exe;
None
}
}