Separate Windows sandbox provisioning from ACL refresh (#42309)

## What changed

- Limit elevated interactive setup to provisioning sandbox identities and proxy settings; do not include caller workspace or ACL roots in its payload.
- Always run the non-elevated setup refresh during sandbox activation so the current permission profile supplies read, write, and deny paths, including when provisioning was completed previously.
- Add an `interactive-provision` setup mode that performs provisioning without the full ACL setup path.

## Testing

- Verify elevated provisioning payloads contain no caller ACL roots and use the new mode.
- Verify the setup helper accepts `interactive-provision` payloads.

GitOrigin-RevId: 081b1b43abd2388773c230fb35da82896e7be2ea
This commit is contained in:
iceweasel-oai authored and copyberry committed 2026-09-02 16:49:45 +00:00
1 parent fc953e5234
commit 1bc8fb16ae
6 files changed
+124 -83

No files matched your search

+25 -20
View File
@@ -99,27 +99,34 @@ pub fn sandbox_setup_is_complete(_codex_home: &Path) -> bool {
}
#[cfg(target_os = "windows")]
pub fn run_elevated_setup(
pub fn prepare_elevated_sandbox(
permission_profile: &PermissionProfile,
workspace_roots: &[AbsolutePathBuf],
command_cwd: &Path,
env_map: &HashMap<String, String>,
codex_home: &Path,
) -> anyhow::Result<()> {
let permissions =
codex_windows_sandbox::ResolvedWindowsSandboxPermissions::try_from_permission_profile_for_workspace_roots(
permission_profile,
workspace_roots,
)?;
codex_windows_sandbox::run_elevated_setup(
codex_windows_sandbox::SandboxSetupRequest {
if !sandbox_setup_is_complete(codex_home) {
let permissions =
codex_windows_sandbox::ResolvedWindowsSandboxPermissions::try_from_permission_profile_for_workspace_roots(
permission_profile,
workspace_roots,
)?;
codex_windows_sandbox::run_elevated_setup(codex_windows_sandbox::SandboxSetupRequest {
permissions: &permissions,
command_cwd,
env_map,
codex_home,
proxy_enforced: false,
},
codex_windows_sandbox::SetupRootOverrides::default(),
})?;
}
codex_windows_sandbox::run_setup_refresh(
permission_profile,
workspace_roots,
command_cwd,
env_map,
codex_home,
/*proxy_enforced*/ false,
)
}
@@ -150,7 +157,7 @@ pub fn run_elevated_provisioning_setup(
}
#[cfg(not(target_os = "windows"))]
pub fn run_elevated_setup(
pub fn prepare_elevated_sandbox(
_permission_profile: &PermissionProfile,
_workspace_roots: &[AbsolutePathBuf],
_command_cwd: &Path,
@@ -286,15 +293,13 @@ async fn run_windows_sandbox_setup_and_persist(
let setup_result = tokio::task::spawn_blocking(move || -> anyhow::Result<()> {
match mode {
WindowsSandboxSetupMode::Elevated => {
if !sandbox_setup_is_complete(setup_codex_home.as_path()) {
run_elevated_setup(
&permission_profile,
workspace_roots.as_slice(),
command_cwd.as_path(),
&env_map,
setup_codex_home.as_path(),
)?;
}
prepare_elevated_sandbox(
&permission_profile,
workspace_roots.as_slice(),
command_cwd.as_path(),
&env_map,
setup_codex_home.as_path(),
)?;
}
WindowsSandboxSetupMode::Unelevated => {
run_legacy_setup_preflight(