Compare commits

...

1 Commits

Author SHA1 Message Date
David Wiesen
4e4bc9ce5b Avoid WindowsApps ACL refresh for copied sandbox helpers 2026-03-22 21:49:04 -07:00

View File

@@ -288,16 +288,13 @@ fn profile_read_roots(user_profile: &Path) -> Vec<PathBuf> {
}
fn gather_helper_read_roots(codex_home: &Path) -> Vec<PathBuf> {
let mut roots = Vec::new();
if let Ok(exe) = std::env::current_exe() {
if let Some(dir) = exe.parent() {
roots.push(dir.to_path_buf());
}
}
let helper_dir = helper_bin_dir(codex_home);
let _ = std::fs::create_dir_all(&helper_dir);
roots.push(helper_dir);
roots
// Sandbox users only need to read helpers from the copied `.sandbox-bin` location.
// Granting ACLs on the original install directory can fail for packaged app paths
// such as `C:\\Program Files\\WindowsApps\\...` and is unnecessary once helpers are
// materialized into CODEX_HOME.
vec![helper_dir]
}
fn gather_legacy_full_read_roots(
@@ -738,6 +735,25 @@ mod tests {
assert!(roots.contains(&expected));
}
#[test]
fn gather_read_roots_excludes_current_executable_directory() {
let tmp = TempDir::new().expect("tempdir");
let codex_home = tmp.path().join("codex-home");
let command_cwd = tmp.path().join("workspace");
fs::create_dir_all(&command_cwd).expect("create workspace");
let policy = SandboxPolicy::new_read_only_policy();
let roots = gather_read_roots(&command_cwd, &policy, &codex_home);
let exe_dir = std::env::current_exe()
.expect("current exe")
.parent()
.expect("current exe parent")
.to_path_buf();
let canonical_exe_dir = dunce::canonicalize(&exe_dir).unwrap_or_else(|_| exe_dir.clone());
assert!(!roots.contains(&canonical_exe_dir));
}
#[test]
fn restricted_read_roots_skip_platform_defaults_when_disabled() {
let tmp = TempDir::new().expect("tempdir");