Files
codex/codex-rs/windows-sandbox-service/src/lib.rs
T
chess b9775a0d57 Honor home deletion preferences during Windows uninstall (#54708)
## What changed

Read `desktop.uninstall_codex_home` from the owner's current `config.toml` before recursively deleting a desktop-created Codex home during Windows sandbox uninstall.

- Preserve the home by default for ordinary installations; retain the deletion default for OEM preinstalls when no preference is set.
- Let an explicit boolean preference override either default. Preserve the home when configuration is unreadable, malformed, or contains an invalid preference.
- Capture OEM metadata before Windows removes it during uninstall, and revoke sandbox permissions on retained homes.

## Testing

Add unit tests for missing preferences, explicit overrides, malformed or invalid configuration, and configuration read failures across both installation defaults.

GitOrigin-RevId: 46afc2a7b0f4ecf7f447e46b515e50d0d278e4a8
2026-10-16 21:00:02 +00:00

46 lines
873 B
Rust

use anyhow::Result;
#[cfg(windows)]
mod installation_record;
#[cfg(windows)]
mod ipc;
#[cfg(windows)]
mod machine_policy;
#[cfg(windows)]
mod package_identity;
#[cfg(windows)]
mod package_lifecycle;
#[cfg(windows)]
mod provisioning;
#[cfg(windows)]
mod registered_runtime;
#[cfg(windows)]
mod service;
#[cfg(any(windows, test))]
mod uninstall_policy;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum RunMode {
Service,
#[cfg(debug_assertions)]
Foreground,
}
pub fn run(mode: RunMode) -> Result<()> {
#[cfg(windows)]
{
match mode {
RunMode::Service => service::run(),
#[cfg(debug_assertions)]
RunMode::Foreground => service::run_foreground(),
}
}
#[cfg(not(windows))]
{
let _ = mode;
anyhow::bail!("the Codex sandbox service is only available on Windows")
}
}