mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
## Summary This is the runtime/foundation half of the Windows sandbox unified-exec work. - add Windows sandbox `unified_exec` session support in `windows-sandbox-rs` for both: - the legacy restricted-token backend - the elevated runner backend - extend the PTY/process runtime so driver-backed sessions can support: - stdin streaming - stdout/stderr separation - exit propagation - PTY resize hooks - add Windows sandbox runtime coverage in `codex-windows-sandbox` / `codex-utils-pty` This PR does **not** enable Windows sandbox `UnifiedExec` for product callers yet because hooking this up to app-server comes in the next PR. Windows sandbox advertising is intentionally kept aligned with `main`, so sandboxed Windows callers still fall back to `ShellCommand`. This PR isolates the runtime/session layer so it can be reviewed independently from product-surface enablement. --------- Co-authored-by: jif-oai <jif@openai.com> Co-authored-by: Codex <noreply@openai.com>
31 lines
943 B
Rust
31 lines
943 B
Rust
use crate::acl::add_deny_write_ace;
|
|
use crate::path_normalization::canonicalize_path;
|
|
use anyhow::Result;
|
|
use std::ffi::c_void;
|
|
use std::path::Path;
|
|
|
|
pub fn is_command_cwd_root(root: &Path, canonical_command_cwd: &Path) -> bool {
|
|
canonicalize_path(root) == canonical_command_cwd
|
|
}
|
|
|
|
/// # Safety
|
|
/// Caller must ensure `psid` is a valid SID pointer.
|
|
pub unsafe fn protect_workspace_codex_dir(cwd: &Path, psid: *mut c_void) -> Result<bool> {
|
|
protect_workspace_subdir(cwd, psid, ".codex")
|
|
}
|
|
|
|
/// # Safety
|
|
/// Caller must ensure `psid` is a valid SID pointer.
|
|
pub unsafe fn protect_workspace_agents_dir(cwd: &Path, psid: *mut c_void) -> Result<bool> {
|
|
protect_workspace_subdir(cwd, psid, ".agents")
|
|
}
|
|
|
|
unsafe fn protect_workspace_subdir(cwd: &Path, psid: *mut c_void, subdir: &str) -> Result<bool> {
|
|
let path = cwd.join(subdir);
|
|
if path.is_dir() {
|
|
add_deny_write_ace(&path, psid)
|
|
} else {
|
|
Ok(false)
|
|
}
|
|
}
|