mirror of
https://github.com/openai/codex.git
synced 2026-11-29 00:00:54 +00:00
## What changed - Dispatch `--__codex-windows-mxc` before normal CLI parsing, launch the decoded request, and propagate the child exit code. - Build the native request from the helper's environment and working directory, discovered Windows platform directories, and volume roots, including UNC working-directory roots. Reject non-Unicode environment values and empty child environments. - Allow Win32k calls and desktop handles needed for PowerShell startup while retaining clipboard, input-injection, and desktop/system-control restrictions. - Keep policy, transport, and native launch internals private, and report an explicit error when the helper is invoked outside Windows. ## Testing Add a wrapper regression test covering exact argument preservation, Windows quoting, separate policy and command working directories, and explicit environment forwarding. GitOrigin-RevId: 674d0d61a3265bd517b77da9f9de2cd9fad62917
44 lines
1.8 KiB
Rust
44 lines
1.8 KiB
Rust
//! Run an already prepared MXC request with inherited stdio and job ownership.
|
|
|
|
use anyhow::Context;
|
|
use anyhow::Result;
|
|
use anyhow::ensure;
|
|
use appcontainer_common::base_container_runner::BaseContainerRunner;
|
|
use learning_mode_windows::SecurityEnvironmentApi;
|
|
use wxc_common::logger::Logger;
|
|
use wxc_common::logger::Mode;
|
|
use wxc_common::models::ExecutionRequest;
|
|
use wxc_common::sandbox_process::SandboxBackend;
|
|
use wxc_common::sandbox_process::StdioMode;
|
|
|
|
// The ETW functions used by tracelogging are documented Advapi32 exports on
|
|
// both Windows toolchains; 1.2.3 leaves their import library to the application.
|
|
#[link(name = "advapi32")]
|
|
unsafe extern "system" {}
|
|
|
|
pub(super) fn launch(request: &ExecutionRequest) -> Result<i32> {
|
|
ensure!(
|
|
!request
|
|
.policy
|
|
.capabilities
|
|
.iter()
|
|
.any(|capability| capability.eq_ignore_ascii_case("permissiveLearningMode")),
|
|
"MXC native launch does not support permissiveLearningMode"
|
|
);
|
|
// With no least-privilege mode, legacy proxy, or capture enabled, this
|
|
// probe guarantees BaseContainerRunner chooses PSEC rather than SBOX.
|
|
if !request.policy.denied_paths.is_empty() {
|
|
ensure!(
|
|
SecurityEnvironmentApi::load()?.supports_deny_paths()?,
|
|
"this Windows build cannot enforce native MXC deny paths"
|
|
);
|
|
}
|
|
let mut logger = Logger::new(Mode::Buffer);
|
|
let mut child = BaseContainerRunner::new()
|
|
.spawn(request, &mut logger, StdioMode::Inherit)
|
|
.map_err(|error| anyhow::anyhow!("{}", error.error_message))?;
|
|
// Do not publish the SDK diagnostic buffer: it may contain command or
|
|
// environment data. This wrapper emits only the resulting launch error.
|
|
child.wait().context("waiting for the MXC command")
|
|
}
|