Skip to content

Commit

Permalink
hostinfo: update Windows hostinfo to include MSIDist registry value
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dblohm7 authored and Asutorufa committed Aug 23, 2024
1 parent f79d06f commit 819d849
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions hostinfo/hostinfo_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand All @@ -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 ""
}
result := "msi"
if env, _ := winutil.GetRegString("MSIDist"); env != "" {
result += "/" + env
}
// Atypical. Not worth trying to detect. Likely open
// source tailscaled or a developer running by hand.
return ""
return result
}

0 comments on commit 819d849

Please sign in to comment.