From 2cb408f9b1c972d5b780dc1ee029977699cb0681 Mon Sep 17 00:00:00 2001 From: Aaron Klotz Date: Tue, 30 Apr 2024 12:23:40 -0600 Subject: [PATCH] hostinfo: update Windows hostinfo to include MSIDist registry value We need to expand our enviornment information to include info about the Windows store. Thinking about future plans, it would be nice to include both the packaging mechanism and the distribution mechanism. In this PR we change packageTypeWindows to check a new registry value named MSIDist, and concatenate that value to "msi/" when present. We also remove vestigial NSIS detection. Updates https://github.com/tailscale/corp/issues/2790 Signed-off-by: Aaron Klotz --- hostinfo/hostinfo_windows.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/hostinfo/hostinfo_windows.go b/hostinfo/hostinfo_windows.go index b789efb28..f0422f5a0 100644 --- a/hostinfo/hostinfo_windows.go +++ b/hostinfo/hostinfo_windows.go @@ -72,10 +72,6 @@ func packageTypeWindows() string { if _, err := os.Stat(`C:\ProgramData\chocolatey\lib\tailscale`); err == nil { return "choco" } - msiSentinel, _ := winutil.GetRegInteger("MSI") - if msiSentinel == 1 { - return "msi" - } exe, err := os.Executable() if err != nil { return "" @@ -84,13 +80,15 @@ func packageTypeWindows() string { if strings.HasPrefix(exe, filepath.Join(home, "scoop", "apps", "tailscale")) { return "scoop" } - dir := filepath.Dir(exe) - nsisUninstaller := filepath.Join(dir, "Uninstall-Tailscale.exe") - _, err = os.Stat(nsisUninstaller) - if err == nil { - return "nsis" + msiSentinel, _ := winutil.GetRegInteger("MSI") + if msiSentinel != 1 { + // Atypical. Not worth trying to detect. Likely open + // source tailscaled or a developer running by hand. + return "" } - // Atypical. Not worth trying to detect. Likely open - // source tailscaled or a developer running by hand. - return "" + result := "msi" + if env, _ := winutil.GetRegString("MSIDist"); env != "" { + result += "/" + env + } + return result }