Always use private desktops for legacy Windows sandboxes (#46554)

## What changed

- Remove the private-desktop opt-out from elevated and unelevated Windows sandbox launches.
- Remove `windows.sandbox_private_desktop` and its managed requirement and API fields. Warn users to remove the obsolete setting.
- Require a private desktop name when launching through the Windows sandbox wrapper and command runner.

## Testing

Add coverage for the obsolete-setting migration warning and update wrapper tests to verify a live private desktop is passed and a missing desktop name is rejected.

GitOrigin-RevId: c7135f8d211aac8d812180691c2c1e433d77cde4
This commit is contained in:
iceweasel-oai
2026-09-18 21:53:33 +00:00
committed by copyberry
parent c6f5d9e9b5
commit a633ebc124
94 changed files with 179 additions and 680 deletions

View File

@@ -197,8 +197,6 @@ impl FileSystemSandboxRunner {
use_legacy_landlock: sandbox_context.use_legacy_landlock,
windows_sandbox_level: windows_sandbox_level
.unwrap_or(WindowsSandboxLevel::Disabled),
windows_sandbox_private_desktop: sandbox_context
.windows_sandbox_private_desktop,
},
})
.map_err(|err| invalid_request(format!("failed to prepare fs sandbox: {err}")))
@@ -885,7 +883,7 @@ mod tests {
),
]);
let sandbox_context = crate::FileSystemSandboxContext {
windows_sandbox_selection: codex_file_system::WindowsSandboxSelection::Elevated,
windows_sandbox_selection: codex_file_system::WindowsSandboxSelection::RestrictedToken,
..sandbox_context_with_cwd(&policy, cwd_uri)
};
selected.close().expect("remove selected directory");

View File

@@ -254,7 +254,6 @@ fn powershell_command(script: &str, path: &Path) -> anyhow::Result<SandboxExecRe
network_environment_id: None,
sandbox: SandboxType::None,
windows_sandbox_level: WindowsSandboxLevel::Disabled,
windows_sandbox_private_desktop: false,
permission_profile: PermissionProfile::Disabled,
arg0: None,
})

View File

@@ -59,7 +59,6 @@ struct PreparedWindowsSandboxRequest {
network_proxy_restricting_sid: Option<String>,
proxy_settings_mode: WindowsSandboxProxySettingsMode,
filesystem_overrides: Option<WindowsSandboxFilesystemOverrides>,
use_private_desktop: bool,
}
impl PreparedExecRequest {
@@ -74,7 +73,6 @@ impl PreparedExecRequest {
network_proxy_restricting_sid: request.network_proxy_restricting_sid.as_deref(),
proxy_settings_mode: request.proxy_settings_mode,
filesystem_overrides: request.filesystem_overrides.as_ref(),
use_private_desktop: request.use_private_desktop,
})
}
}
@@ -90,9 +88,9 @@ pub(crate) async fn prepare_exec_request_with_telemetry(
if let Some(sandbox) = params.sandbox.as_ref()
&& sandbox.windows_sandbox_selection == WindowsSandboxSelection::Mxc
{
if params.arg0.is_some() || sandbox.windows_sandbox_private_desktop {
if params.arg0.is_some() {
return Err(invalid_params(
"MXC custom argv0 and private-desktop launches are not supported".to_owned(),
"MXC custom argv0 is not supported".to_owned(),
));
}
if !codex_sandboxing::windows_mxc_available() {
@@ -271,7 +269,6 @@ pub(crate) async fn prepare_exec_request_with_telemetry(
},
use_legacy_landlock: sandbox_context.use_legacy_landlock,
windows_sandbox_level: windows_sandbox_level.unwrap_or(WindowsSandboxLevel::Disabled),
windows_sandbox_private_desktop: sandbox_context.windows_sandbox_private_desktop,
},
};
let mut request = if sandbox == SandboxType::WindowsRestrictedToken {
@@ -312,7 +309,6 @@ pub(crate) async fn prepare_exec_request_with_telemetry(
network_proxy_restricting_sid,
proxy_settings_mode: windows_sandbox_proxy_settings_mode,
filesystem_overrides,
use_private_desktop: sandbox_context.windows_sandbox_private_desktop,
})
} else {
None

View File

@@ -569,8 +569,7 @@ async fn file_system_private_desktop_survives_helper_exits_and_separates_permiss
let path = tmp.path().join("contents.txt");
std::fs::write(&path, b"initial")?;
let uri = PathUri::from_host_native_path(&path)?;
let mut sandbox = workspace_write_sandbox(tmp.path().to_path_buf());
sandbox.windows_sandbox_private_desktop = true;
let sandbox = workspace_write_sandbox(tmp.path().to_path_buf());
let before = process_private_desktops()?;
let write = file_system
.write_file(
@@ -624,7 +623,6 @@ async fn file_system_private_desktop_survives_helper_exits_and_separates_permiss
let mut readonly = read_only_sandbox_for_cwd(tmp.path().to_path_buf())?;
readonly.windows_sandbox_selection = WindowsSandboxSelection::RestrictedToken;
readonly.windows_sandbox_private_desktop = true;
file_system
.write_file(
&uri,