Reuse private desktops across Windows sandbox commands (#40672)

## Why

Private desktops need to remain available across command-runner exits and idle
gaps.

## What changed

- Keep parent-owned private desktops alive and reuse them only when the sandbox
  account and effective permissions match.
- Pass the selected desktop name to elevated command runners, which validate and
  open the existing desktop instead of creating their own.
- Apply the same policy-aware reuse to the legacy Windows sandbox path.

## Testing

Add Windows tests for desktop-name validation, lifetime and concurrent reuse,
and separation when effective permissions differ.

GitOrigin-RevId: 2df8b1c31ff22d72549f2ec3065cd80ea1dd0c6a
This commit is contained in:
chess authored and copyberry committed 2026-08-25 18:41:03 +00:00
1 parent 731d969d03
commit 7e1ee6df6c
16 files changed
+642 -33

No files matched your search

+12 -3
View File
@@ -576,7 +576,16 @@ mod windows_impl {
)?;
let (stdin_pair, stdout_pair, stderr_pair) = unsafe { setup_stdio_pipes()? };
let ((in_r, in_w), (out_r, out_w), (err_r, err_w)) = (stdin_pair, stdout_pair, stderr_pair);
let spawn_res = unsafe {
let spawn_res = crate::LaunchDesktop::prepare_legacy(
use_private_desktop,
&permissions,
&current_dir,
&env_map,
&security,
&additional_deny_write_paths,
logs_base_dir,
)
.and_then(|desktop| unsafe {
create_process_as_user(
security.h_token,
&command,
@@ -585,9 +594,9 @@ mod windows_impl {
logs_base_dir,
Some((in_r, out_w, err_w)),
ConsoleMode::Inherit,
use_private_desktop,
desktop,
)
};
});
let created = match spawn_res {
Ok(v) => v,
Err(err) => {