mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
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
This commit is contained in:
1 parent
a14ef02e1c
commit
665e5f45ab
25 files changed
+1349
-97
No files matched your search
@@ -1,6 +1,8 @@
|
||||
use crate::dpapi;
|
||||
use crate::logging::debug_log;
|
||||
use crate::resolved_permissions::ResolvedWindowsSandboxPermissions;
|
||||
use crate::setup::OFFLINE_USERNAME;
|
||||
use crate::setup::ONLINE_USERNAME;
|
||||
use crate::setup::SandboxNetworkIdentity;
|
||||
use crate::setup::SandboxUserRecord;
|
||||
use crate::setup::SandboxUsersFile;
|
||||
@@ -12,6 +14,7 @@ use crate::setup::run_elevated_setup_with_proxy_settings;
|
||||
use crate::setup::run_setup_refresh_with_overrides_and_proxy_settings;
|
||||
use crate::setup::sandbox_users_path;
|
||||
use crate::setup::setup_marker_path;
|
||||
use crate::winutil::local_user_flags;
|
||||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use anyhow::anyhow;
|
||||
@@ -21,6 +24,7 @@ use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use windows_sys::Win32::NetworkManagement::NetManagement::UF_ACCOUNTDISABLE;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct SandboxIdentity {
|
||||
@@ -217,6 +221,23 @@ pub fn require_logon_sandbox_creds(
|
||||
}
|
||||
};
|
||||
|
||||
if identity.is_some() {
|
||||
// Cleanup may also have removed the group, so repair missing or disabled accounts before ACL
|
||||
// refresh can fail, not only after a later logon reports ERROR_ACCOUNT_DISABLED.
|
||||
for username in [OFFLINE_USERNAME, ONLINE_USERNAME] {
|
||||
let needs_repair = match local_user_flags(username) {
|
||||
Ok(Some(flags)) => flags & UF_ACCOUNTDISABLE != 0,
|
||||
Ok(None) => true,
|
||||
Err(_) => false,
|
||||
};
|
||||
if needs_repair {
|
||||
setup_reason = Some("sandbox account is missing or disabled".to_string());
|
||||
identity = None;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if identity.is_none() {
|
||||
if let Some(reason) = &setup_reason {
|
||||
crate::logging::log_note(
|
||||
|
||||
Reference in new issue
Block a user