Preserve SystemRoot for Windows sandbox wrapper setup (#42833)

## Why

`ShellExecuteExW` needs `SystemRoot` to elevate the Windows sandbox setup helper.

## What changed

Add `SYSTEMROOT` to the environment variables copied from the host for wrapper
setup. Keep the serialized inner command environment unchanged so the host value
is available only to the wrapper.

## Testing

Extend Windows sandbox manager tests to cover case-insensitive replacement of
`SystemRoot` and verify that it is excluded from the inner command environment.

GitOrigin-RevId: c69f9f92665e97a178e2de488fbb9fd6b7ff7ac6
This commit is contained in:
zm-oai authored and copyberry committed 2026-09-04 19:22:34 +00:00
1 parent 87628df77a
commit f1aac1e885
2 files changed
+22 -2

No files matched your search

+6 -1
View File
@@ -31,7 +31,12 @@ use std::io;
use std::path::Path;
#[cfg(target_os = "windows")]
const WINDOWS_SANDBOX_WRAPPER_SETUP_ENV_ALLOWLIST: &[&str] = &["USERNAME", "USERPROFILE"];
const WINDOWS_SANDBOX_WRAPPER_SETUP_ENV_ALLOWLIST: &[&str] = &[
"USERNAME",
"USERPROFILE",
// ShellExecuteExW needs SystemRoot to elevate the setup helper.
"SYSTEMROOT",
];
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SandboxType {