Add service-managed package registration for Windows sandbox accounts (#45542)

## What changed

- Add an explicit `registered_core` provisioning mode that registers the app package for both managed sandbox accounts and records their runner aliases. Authenticate callers against the service's package family and installed version.
- Persist runtime ownership and publish readiness only after both registrations and AppData metadata grants succeed. Prevent legacy setup or another owner from replacing registered sandbox accounts, and restrict `refresh_only` requests to an existing ready setup.
- Scope service and pipe names by package identity.
- Preserve registrations across package updates and clean them up when the owner uninstalls the app. Fence provisioning during teardown and defer package removal until native cleanup succeeds and the service exits.

## Testing

Add tests for registration opt-in, ownership and readiness checks, legacy setup isolation, metadata ACL preservation, listener shutdown handling, and the cleanup finalizer's commit barrier and UTF-8 input.

GitOrigin-RevId: 69e52f7463285b51f3bef831f071245f0eca0838
This commit is contained in:
zm-oai authored and copyberry committed 2026-09-14 23:24:10 +00:00
1 parent 18d7ace221
commit 6ae5e71458
50 files changed
+3515 -169

No files matched your search

+2 -2
View File
@@ -193,7 +193,7 @@ pub unsafe fn get_current_token_for_restriction() -> Result<HANDLE> {
/// An owned token group, including attributes such as enabled and deny-only.
#[derive(Debug, PartialEq, Eq)]
pub(crate) struct TokenGroup {
pub struct TokenGroup {
pub sid: Vec<u8>,
pub attributes: u32,
}
@@ -202,7 +202,7 @@ pub(crate) struct TokenGroup {
///
/// # Safety
/// `token` must remain a valid token handle with `TOKEN_QUERY` access during this call.
pub(crate) unsafe fn token_groups(token: HANDLE, max_bytes: u32) -> Result<Vec<TokenGroup>> {
pub unsafe fn token_groups(token: HANDLE, max_bytes: u32) -> Result<Vec<TokenGroup>> {
let mut needed = 0;
GetTokenInformation(token, TokenGroups, std::ptr::null_mut(), 0, &mut needed);
ensure!(