Files
codex/codex-rs/windows-sandbox-service/src/lib.rs
T
chess 665e5f45ab Clean up Windows sandbox resources on app uninstall (#42375)
## What changed

- Record the authenticated sandbox owner and observe package uninstall events across service restarts and session changes.
- During uninstall, serialize setup and cleanup, disable sandbox accounts, stop their processes, and remove sandbox directories, firewall and WFP rules, hidden-user entries, accounts, and the sandbox group.
- Restrict desktop-owned directory cleanup to pinned paths and perform it while impersonating the authenticated owner.
- Detect missing or disabled sandbox accounts after interrupted cleanup and reprovision them before restoring network access.

GitOrigin-RevId: 7d63fff7ddcff3eb01d018653146df12044bd277
2026-09-02 22:19:51 +00:00

39 lines
749 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 service;
#[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")
}
}