Files
tailscale/util/winutil/sideloading_windows.go
T
Nick Khyl 106ddfc24b util/winutil, cmd/tailscaled: log and report app sideloading state
The Windowed UI depends on the Windows App Runtime, which cannot be
installed unless app sideloading or Developer Mode is enabled.
Sideloading is disabled by default on Windows builds older than 19041,
and can be disabled by the user or by policy on newer ones.

Add winutil.GetSideloadingState to read the settings, log the result
when tailscaled starts, and add gauges for sideloading being disabled
by policy, by the user or by default. Builds older than 17763 cannot
run the Windows App Runtime at all, so they are reported as unsupported
and do not count towards any of the gauges.

Updates tailscale/corp#52316

Change-Id: I93d1975e0a54d65d7e692dbf81480d9fdb37a574
Signed-off-by: Nick Khyl <[email protected]>
(cherry picked from commit d4f3bdd0a8)
2026-11-30 15:57:25 -08:00

41 lines
1.2 KiB
Go

// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause
package winutil
import (
"golang.org/x/sys/windows"
"golang.org/x/sys/windows/registry"
)
const (
regSideloadingPolicy = `SOFTWARE\Policies\Microsoft\Windows\Appx`
regSideloadingLocal = `SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock`
)
// GetSideloadingState returns the current [SideloadingState].
func GetSideloadingState() SideloadingState {
_, _, build := windows.RtlGetNtVersionNumbers()
return SideloadingState{
Build: build,
PolicyAllowAllTrustedApps: sideloadingSetting(regSideloadingPolicy, "AllowAllTrustedApps"),
PolicyDevMode: sideloadingSetting(regSideloadingPolicy, "AllowDevelopmentWithoutDevLicense"),
LocalAllowAllTrustedApps: sideloadingSetting(regSideloadingLocal, "AllowAllTrustedApps"),
LocalDevMode: sideloadingSetting(regSideloadingLocal, "AllowDevelopmentWithoutDevLicense"),
}
}
func sideloadingSetting(subKey, name string) *uint32 {
key, err := registry.OpenKey(registry.LOCAL_MACHINE, subKey, registry.QUERY_VALUE)
if err != nil {
return nil
}
defer key.Close()
val, _, err := key.GetIntegerValue(name)
if err != nil {
return nil
}
return new(uint32(val))
}