mirror of
https://github.com/openai/codex.git
synced 2026-11-13 06:45:07 +00:00
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
This commit is contained in:
1 parent
853d98b6b0
commit
104e25ac5a
2 files changed
+8
-5
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
use std::ffi::c_void;
|
use std::ffi::c_void;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
use std::os::windows::fs::MetadataExt as _;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use anyhow::Result;
|
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 codex_windows_sandbox::path_mask_allows;
|
||||||
use windows_sys::Win32::Security::CONTAINER_INHERIT_ACE;
|
use windows_sys::Win32::Security::CONTAINER_INHERIT_ACE;
|
||||||
use windows_sys::Win32::Security::OBJECT_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_EXECUTE;
|
||||||
use windows_sys::Win32::Storage::FileSystem::FILE_GENERIC_READ;
|
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 {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +96,7 @@ fn runtime_paths(local_app_data: Option<PathBuf>, user_profile: Option<PathBuf>)
|
|||||||
let mut runtime_paths = Vec::new();
|
let mut runtime_paths = Vec::new();
|
||||||
if let Some(local_app_data) = local_app_data {
|
if let Some(local_app_data) = local_app_data {
|
||||||
let codex_root = local_app_data.join("OpenAI").join("Codex");
|
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.
|
// The managed primary runtime is installed outside the LocalAppData runtime roots.
|
||||||
if let Some(user_profile) = user_profile {
|
if let Some(user_profile) = user_profile {
|
||||||
|
|||||||
@@ -3,15 +3,14 @@ use pretty_assertions::assert_eq;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[test]
|
#[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 local_app_data = PathBuf::from(r"C:\Users\user\AppData\Local");
|
||||||
let user_profile = PathBuf::from(r"C:\Users\user");
|
let user_profile = PathBuf::from(r"C:\Users\user");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
runtime_paths(Some(local_app_data), Some(user_profile)),
|
runtime_paths(Some(local_app_data), Some(user_profile)),
|
||||||
vec![
|
vec![
|
||||||
PathBuf::from(r"C:\Users\user\AppData\Local\OpenAI\Codex\bin"),
|
PathBuf::from(r"C:\Users\user\AppData\Local\OpenAI\Codex"),
|
||||||
PathBuf::from(r"C:\Users\user\AppData\Local\OpenAI\Codex\runtimes"),
|
|
||||||
PathBuf::from(r"C:\Users\user\.cache\codex-runtimes"),
|
PathBuf::from(r"C:\Users\user\.cache\codex-runtimes"),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user