mirror of
https://github.com/openai/codex.git
synced 2026-09-11 20:36:49 +00:00
## What changed - Add the macOS-only `allow_symlinked_codex_home` user setting. When enabled in the execution host's `$CODEX_HOME/config.toml`, writable roots at or beneath that home may traverse symlinks. - Keep the exception disabled by default and prevent project config, command-line overrides, and ignored user config from enabling it. Other writable roots remain subject to symlink checks. - Propagate the resolved setting through local, interactive, and exec-server sandbox paths, including `CODEX_HOME` aliases. - Explain the opt-out in symlink rejection errors, including that it trusts targets outside `CODEX_HOME` and targets that change between commands. ## Testing - Add macOS coverage for shell commands, patches, filesystem helpers, process execution, and interactive startup with enabled, disabled, aliased, and out-of-scope homes. GitOrigin-RevId: 99fcdf611200c9e1b7713cf06f7fdea5bfa7f089
59 lines
2.1 KiB
Rust
59 lines
2.1 KiB
Rust
use std::path::PathBuf;
|
|
|
|
use codex_utils_absolute_path::AbsolutePathBuf;
|
|
|
|
/// Paths and sandbox settings initialized when creating an executor.
|
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
pub struct ExecServerRuntimePaths {
|
|
/// Stable path to the Codex executable used to launch hidden helper modes.
|
|
pub codex_self_exe: AbsolutePathBuf,
|
|
/// Path to the Linux sandbox helper alias used when the platform sandbox
|
|
/// needs to re-enter Codex by argv0.
|
|
pub codex_linux_sandbox_exe: Option<AbsolutePathBuf>,
|
|
/// User-config opt-out of writable-root symlink checks beneath this host's home.
|
|
#[cfg(target_os = "macos")]
|
|
pub allowed_symlinked_codex_home: Option<AbsolutePathBuf>,
|
|
}
|
|
|
|
impl ExecServerRuntimePaths {
|
|
pub fn from_optional_paths(
|
|
codex_self_exe: Option<PathBuf>,
|
|
codex_linux_sandbox_exe: Option<PathBuf>,
|
|
) -> std::io::Result<Self> {
|
|
let codex_self_exe = codex_self_exe.ok_or_else(|| {
|
|
std::io::Error::new(
|
|
std::io::ErrorKind::InvalidInput,
|
|
"Codex executable path is not configured",
|
|
)
|
|
})?;
|
|
Self::new(codex_self_exe, codex_linux_sandbox_exe)
|
|
}
|
|
|
|
pub fn new(
|
|
codex_self_exe: PathBuf,
|
|
codex_linux_sandbox_exe: Option<PathBuf>,
|
|
) -> std::io::Result<Self> {
|
|
Ok(Self {
|
|
codex_self_exe: absolute_path(codex_self_exe)?,
|
|
codex_linux_sandbox_exe: codex_linux_sandbox_exe.map(absolute_path).transpose()?,
|
|
#[cfg(target_os = "macos")]
|
|
allowed_symlinked_codex_home: None,
|
|
})
|
|
}
|
|
|
|
/// Applies the symlink opt-in resolved by the execution host's config loader.
|
|
#[cfg(target_os = "macos")]
|
|
pub fn with_allowed_symlinked_codex_home(
|
|
mut self,
|
|
allowed_symlinked_codex_home: Option<AbsolutePathBuf>,
|
|
) -> Self {
|
|
self.allowed_symlinked_codex_home = allowed_symlinked_codex_home;
|
|
self
|
|
}
|
|
}
|
|
|
|
fn absolute_path(path: PathBuf) -> std::io::Result<AbsolutePathBuf> {
|
|
AbsolutePathBuf::from_absolute_path(path.as_path())
|
|
.map_err(|err| std::io::Error::new(std::io::ErrorKind::InvalidInput, err))
|
|
}
|