Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

exec-server: preserve fs helper CoreFoundation env (#25118)

starr-openaia717e4ef31f6
diff --git a/codex-rs/exec-server/src/fs_sandbox.rs b/codex-rs/exec-server/src/fs_sandbox.rs
index 111d153176..8ef20b2d1d 100644
--- a/codex-rs/exec-server/src/fs_sandbox.rs
+++ b/codex-rs/exec-server/src/fs_sandbox.rs
@@ -230,6 +230,8 @@ fn helper_env_from_vars(
fn helper_env_key_is_allowed(key: &str) -> bool {
FS_HELPER_ENV_ALLOWLIST.contains(&key)
+ // CoreFoundation consults this before falling back to user lookup during helper startup.
+ || (cfg!(target_os = "macos") && key == "__CF_USER_TEXT_ENCODING")
|| bazel_bwrap_env_key_is_allowed(key)
|| (cfg!(windows) && key.eq_ignore_ascii_case("PATH"))
}
@@ -434,6 +436,26 @@ mod tests {
);
}
+ #[cfg(target_os = "macos")]
+ #[test]
+ fn helper_env_preserves_corefoundation_text_encoding() {
+ let env = helper_env_from_vars(
+ [
+ ("__CF_USER_TEXT_ENCODING", "0x1F6:0x0:0x0"),
+ ("HOME", "/Users/test"),
+ ]
+ .map(|(key, value)| (OsString::from(key), OsString::from(value))),
+ );
+
+ assert_eq!(
+ env,
+ HashMap::from([(
+ "__CF_USER_TEXT_ENCODING".to_string(),
+ "0x1F6:0x0:0x0".to_string(),
+ )])
+ );
+ }
+
#[cfg(windows)]
#[test]
fn helper_env_preserves_windows_path_key_for_system_bwrap_discovery() {