Allow trusted symlinks beneath CODEX_HOME on macOS (#42716)

## 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
This commit is contained in:
jif
2026-09-04 10:12:03 +00:00
committed by copyberry
parent 8e6a44b428
commit d13aeb77ea
24 changed files with 499 additions and 36 deletions
@@ -102,7 +102,13 @@ impl ExecServerHarness {
command.stdout(Stdio::piped());
command.stderr(Stdio::inherit());
command.kill_on_drop(true);
command.env("CODEX_HOME", codex_home.path());
if !command
.as_std()
.get_envs()
.any(|(key, value)| key == "CODEX_HOME" && value.is_some())
{
command.env("CODEX_HOME", codex_home.path());
}
let mut child = command.spawn()?;
let websocket_url = read_listen_url_from_stdout(&mut child).await?;
+26 -7
View File
@@ -222,13 +222,32 @@ fn maybe_run_exec_server_from_test_binary(guard: Option<&TestBinaryDispatchGuard
std::process::exit(1);
}
};
let exit_code = match runtime.block_on(codex_exec_server::run_main_with_telemetry(
&listen_url,
runtime_paths,
ExecServerTelemetry::default(),
http_client_factory,
request_dispatch_mode,
)) {
let exit_code = match runtime.block_on(async {
#[cfg(target_os = "macos")]
let runtime_paths = {
let home = codex_utils_home_dir::find_codex_home()?;
let config = codex_config::loader::load_config_layers_state(
&codex_exec_server::LocalFileSystem::unsandboxed(),
home.as_path(),
/*cwd*/ None,
&[],
codex_config::LoaderOverrides::default(),
&codex_config::NoopThreadConfigLoader,
)
.await?;
runtime_paths.with_allowed_symlinked_codex_home(
codex_config::allowed_symlinked_codex_home(&config, &home),
)
};
codex_exec_server::run_main_with_telemetry(
&listen_url,
runtime_paths,
ExecServerTelemetry::default(),
http_client_factory,
request_dispatch_mode,
)
.await
}) {
Ok(()) => 0,
Err(error) => {
eprintln!("exec-server failed: {error}");