mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
b2344d8fbc
## Why #23764 removed Windows resource stamping from `codex-windows-sandbox`, but it also removed the setup helper's UAC manifest. That manifest was doing more than cosmetic version metadata: Microsoft documents `requestedExecutionLevel level="asInvoker"` as the setting that makes an executable run at the same permission level as the process that started it: https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests#trustinfo In the reported session, `codex-windows-sandbox-setup.exe` was launched for a non-elevated setup refresh and `CreateProcess` failed with `os error 740` (`The requested operation requires elevation`). Restoring an explicit `asInvoker` manifest records the helper's intended default launch contract: normal launches inherit the caller's token, and elevation only happens through the code paths that request it explicitly. The setup helper has two launch modes: - setup refresh uses a normal `Command::new(...)` spawn and should never trigger UAC - full setup explicitly uses `ShellExecuteExW` with the `runas` verb when elevation is required Restoring `asInvoker` keeps refresh non-elevated by default while preserving the explicit elevated path for full setup. ## What changed - Restored a minimal `codex-windows-sandbox-setup.manifest` containing only `requestedExecutionLevel level="asInvoker"`. - Added a small build script that passes setup-helper-scoped manifest linker args for MSVC and the Windows GNU/LLVM target used by Bazel. - Wired the manifest into Bazel build-script data. This does not restore `winres`, `FileDescription`, `ProductName`, or package-wide resource stamping, so other Codex binaries that link `codex-windows-sandbox` do not inherit metadata from this package. ## Verification - `cargo fmt -p codex-windows-sandbox` - `cargo build -p codex-windows-sandbox --bin codex-windows-sandbox-setup` - `cargo build -p codex-windows-sandbox --bin codex-command-runner` - `cargo build -p codex-windows-sandbox --lib` - Build-script output simulation for `CARGO_CFG_TARGET_ENV=msvc` emits `/MANIFEST:EMBED` and `/MANIFESTINPUT:<manifest>`. - Build-script output simulation for `CARGO_CFG_TARGET_ENV=gnu` + `CARGO_CFG_TARGET_ABI=llvm` emits `-Wl,-Xlink=/manifest:embed` and `-Wl,-Xlink=/manifestinput:<manifest>`. - Inspected the built binaries and confirmed: - `codex-windows-sandbox-setup.exe` contains `requestedExecutionLevel` / `asInvoker` - `codex-command-runner.exe` does not contain those manifest strings - Windows `VersionInfo` remains blank for `FileDescription` / `ProductName` - `just test -p codex-windows-sandbox` ran through Nextest, with 114 passing, 2 skipped, and 1 existing Windows sandbox failure: `unified_exec::tests::legacy_non_tty_cmd_emits_output` fails with `CreateRestrictedToken failed: 87`.
97 lines
2.4 KiB
TOML
97 lines
2.4 KiB
TOML
[package]
|
|
build = "build.rs"
|
|
edition.workspace = true
|
|
license.workspace = true
|
|
name = "codex-windows-sandbox"
|
|
version.workspace = true
|
|
|
|
[lib]
|
|
name = "codex_windows_sandbox"
|
|
path = "src/lib.rs"
|
|
doctest = false
|
|
|
|
[[bin]]
|
|
name = "codex-windows-sandbox-setup"
|
|
path = "src/bin/setup_main/main.rs"
|
|
|
|
[[bin]]
|
|
name = "codex-command-runner"
|
|
path = "src/bin/command_runner/main.rs"
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[dependencies]
|
|
anyhow = "1.0"
|
|
base64 = { workspace = true }
|
|
chrono = { version = "0.4.42", default-features = false, features = [
|
|
"clock",
|
|
"std",
|
|
] }
|
|
codex-utils-pty = { workspace = true }
|
|
codex-utils-absolute-path = { workspace = true }
|
|
codex-utils-string = { workspace = true }
|
|
codex-otel = { workspace = true }
|
|
dunce = "1.0"
|
|
glob = { workspace = true }
|
|
serde = { version = "1.0", features = ["derive"] }
|
|
serde_json = "1.0"
|
|
tempfile = "3"
|
|
tokio = { workspace = true, features = ["sync", "rt"] }
|
|
tracing-appender = { workspace = true }
|
|
windows = { version = "0.58", features = [
|
|
"Win32_Foundation",
|
|
"Win32_NetworkManagement_WindowsFirewall",
|
|
"Win32_System_Com",
|
|
"Win32_System_Variant",
|
|
] }
|
|
|
|
[dependencies.codex-protocol]
|
|
package = "codex-protocol"
|
|
path = "../protocol"
|
|
|
|
[dependencies.rand]
|
|
default-features = false
|
|
features = ["std", "small_rng"]
|
|
version = "0.8"
|
|
|
|
[dependencies.dirs-next]
|
|
version = "2.0"
|
|
|
|
[target.'cfg(windows)'.dependencies.windows-sys]
|
|
features = [
|
|
"Win32_Foundation",
|
|
"Win32_System_Diagnostics_Debug",
|
|
"Win32_Security",
|
|
"Win32_Security_Authorization",
|
|
"Win32_System_Threading",
|
|
"Win32_System_JobObjects",
|
|
"Win32_System_SystemServices",
|
|
"Win32_System_Environment",
|
|
"Win32_System_Pipes",
|
|
"Win32_System_WindowsProgramming",
|
|
"Win32_System_IO",
|
|
"Win32_System_Memory",
|
|
"Win32_System_Kernel",
|
|
"Win32_System_Console",
|
|
"Win32_Storage_FileSystem",
|
|
"Win32_System_Diagnostics_ToolHelp",
|
|
"Win32_NetworkManagement_NetManagement",
|
|
"Win32_NetworkManagement_WindowsFilteringPlatform",
|
|
"Win32_Networking_WinSock",
|
|
"Win32_System_LibraryLoader",
|
|
"Win32_System_Com",
|
|
"Win32_Security_Cryptography",
|
|
"Win32_Security_Authentication_Identity",
|
|
"Win32_System_Rpc",
|
|
"Win32_Graphics_Gdi",
|
|
"Win32_System_StationsAndDesktops",
|
|
"Win32_UI_WindowsAndMessaging",
|
|
"Win32_UI_Shell",
|
|
"Win32_System_Registry",
|
|
]
|
|
version = "0.52"
|
|
|
|
[dev-dependencies]
|
|
pretty_assertions = { workspace = true }
|