From 104e25ac5aec760d8804d10729e65f6728eb0331 Mon Sep 17 00:00:00 2001 From: zm-oai Date: Tue, 11 Aug 2026 19:41:11 +0000 Subject: [PATCH] Grant Windows sandbox access to the Codex app root (#38064) ## What changed - Apply the sandbox read/execute ACL to the local Codex application root so it inherits across its contents, while continuing to handle the managed runtime cache separately. - Skip missing paths, non-directories, and directory reparse points before inspecting or updating ACLs. - Update the runtime path test to expect the application root. GitOrigin-RevId: 34f2946d2140f8ea2b76c449b0e5542b99cb6f70 --- .../src/bin/setup_main/win/setup_runtime_bin.rs | 8 ++++++-- .../src/bin/setup_main/win/setup_runtime_bin_tests.rs | 5 ++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/codex-rs/windows-sandbox-rs/src/bin/setup_main/win/setup_runtime_bin.rs b/codex-rs/windows-sandbox-rs/src/bin/setup_main/win/setup_runtime_bin.rs index 8b0498d756..176ef07504 100644 --- a/codex-rs/windows-sandbox-rs/src/bin/setup_main/win/setup_runtime_bin.rs +++ b/codex-rs/windows-sandbox-rs/src/bin/setup_main/win/setup_runtime_bin.rs @@ -1,5 +1,6 @@ use std::ffi::c_void; use std::io::Write; +use std::os::windows::fs::MetadataExt as _; use std::path::PathBuf; use anyhow::Result; @@ -7,6 +8,7 @@ use codex_windows_sandbox::ensure_allow_mask_aces_with_inheritance; use codex_windows_sandbox::path_mask_allows; use windows_sys::Win32::Security::CONTAINER_INHERIT_ACE; use windows_sys::Win32::Security::OBJECT_INHERIT_ACE; +use windows_sys::Win32::Storage::FileSystem::FILE_ATTRIBUTE_REPARSE_POINT; use windows_sys::Win32::Storage::FileSystem::FILE_GENERIC_EXECUTE; use windows_sys::Win32::Storage::FileSystem::FILE_GENERIC_READ; @@ -26,7 +28,9 @@ pub(super) fn ensure_codex_app_runtime_paths_readable( ); for runtime_path in runtime_paths { - if !runtime_path.is_dir() { + if !std::fs::symlink_metadata(&runtime_path).is_ok_and(|metadata| { + metadata.is_dir() && (metadata.file_attributes() & FILE_ATTRIBUTE_REPARSE_POINT) == 0 + }) { continue; } @@ -92,7 +96,7 @@ fn runtime_paths(local_app_data: Option, user_profile: Option) let mut runtime_paths = Vec::new(); if let Some(local_app_data) = local_app_data { let codex_root = local_app_data.join("OpenAI").join("Codex"); - runtime_paths.extend([codex_root.join("bin"), codex_root.join("runtimes")]); + runtime_paths.push(codex_root); } // The managed primary runtime is installed outside the LocalAppData runtime roots. if let Some(user_profile) = user_profile { diff --git a/codex-rs/windows-sandbox-rs/src/bin/setup_main/win/setup_runtime_bin_tests.rs b/codex-rs/windows-sandbox-rs/src/bin/setup_main/win/setup_runtime_bin_tests.rs index a3fa300d0b..ad8aa7c3e4 100644 --- a/codex-rs/windows-sandbox-rs/src/bin/setup_main/win/setup_runtime_bin_tests.rs +++ b/codex-rs/windows-sandbox-rs/src/bin/setup_main/win/setup_runtime_bin_tests.rs @@ -3,15 +3,14 @@ use pretty_assertions::assert_eq; use std::path::PathBuf; #[test] -fn runtime_paths_include_desktop_and_primary_runtime_roots() { +fn runtime_paths_include_desktop_parent_and_primary_runtime_roots() { let local_app_data = PathBuf::from(r"C:\Users\user\AppData\Local"); let user_profile = PathBuf::from(r"C:\Users\user"); assert_eq!( runtime_paths(Some(local_app_data), Some(user_profile)), vec![ - PathBuf::from(r"C:\Users\user\AppData\Local\OpenAI\Codex\bin"), - PathBuf::from(r"C:\Users\user\AppData\Local\OpenAI\Codex\runtimes"), + PathBuf::from(r"C:\Users\user\AppData\Local\OpenAI\Codex"), PathBuf::from(r"C:\Users\user\.cache\codex-runtimes"), ] );