mirror of
https://github.com/openai/codex.git
synced 2026-05-02 02:17:22 +00:00
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:
@@ -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, ¤t_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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user