mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-27 10:47:35 +00:00
hostinfo: use the sentinel value set by the MSI installer to detect MSI package type
The MSI installer sets a special sentinel value that we can use to detect it. I also removed the code that bails out when the installation path is not `Program Files`, as both the NSIS and MSI installers permit the user to install to a different path. Signed-off-by: Aaron Klotz <aaron@tailscale.com>
This commit is contained in:
parent
4fee321004
commit
e31d68d64e
@ -81,6 +81,8 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep
|
|||||||
W tailscale.com/util/endian from tailscale.com/net/netns
|
W tailscale.com/util/endian from tailscale.com/net/netns
|
||||||
tailscale.com/util/groupmember from tailscale.com/cmd/tailscale/cli
|
tailscale.com/util/groupmember from tailscale.com/cmd/tailscale/cli
|
||||||
tailscale.com/util/lineread from tailscale.com/net/interfaces+
|
tailscale.com/util/lineread from tailscale.com/net/interfaces+
|
||||||
|
W tailscale.com/util/winutil from tailscale.com/hostinfo
|
||||||
|
W 💣 tailscale.com/util/winutil/vss from tailscale.com/util/winutil
|
||||||
tailscale.com/version from tailscale.com/cmd/tailscale/cli+
|
tailscale.com/version from tailscale.com/cmd/tailscale/cli+
|
||||||
tailscale.com/version/distro from tailscale.com/cmd/tailscale/cli+
|
tailscale.com/version/distro from tailscale.com/cmd/tailscale/cli+
|
||||||
tailscale.com/wgengine/filter from tailscale.com/types/netmap
|
tailscale.com/wgengine/filter from tailscale.com/types/netmap
|
||||||
|
@ -8,11 +8,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
"golang.org/x/sys/windows/registry"
|
"golang.org/x/sys/windows/registry"
|
||||||
|
"tailscale.com/util/winutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -65,32 +65,20 @@ func packageTypeWindows() string {
|
|||||||
if _, err := os.Stat(`C:\ProgramData\chocolatey\lib\tailscale`); err == nil {
|
if _, err := os.Stat(`C:\ProgramData\chocolatey\lib\tailscale`); err == nil {
|
||||||
return "choco"
|
return "choco"
|
||||||
}
|
}
|
||||||
|
if msiSentinel := winutil.GetRegInteger("MSI", 0); msiSentinel == 1 {
|
||||||
|
return "msi"
|
||||||
|
}
|
||||||
exe, err := os.Executable()
|
exe, err := os.Executable()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
dir := filepath.Dir(exe)
|
dir := filepath.Dir(exe)
|
||||||
if !strings.Contains(dir, "Program Files") {
|
|
||||||
// Atypical. Not worth trying to detect. Likely open
|
|
||||||
// source tailscaled or a developer running by hand.
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
nsisUninstaller := filepath.Join(dir, "Uninstall-Tailscale.exe")
|
nsisUninstaller := filepath.Join(dir, "Uninstall-Tailscale.exe")
|
||||||
_, err = os.Stat(nsisUninstaller)
|
_, err = os.Stat(nsisUninstaller)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return "nsis"
|
return "nsis"
|
||||||
}
|
}
|
||||||
if os.IsNotExist(err) {
|
// Atypical. Not worth trying to detect. Likely open
|
||||||
_, cliErr := os.Stat(filepath.Join(dir, "tailscale.exe"))
|
// source tailscaled or a developer running by hand.
|
||||||
_, daemonErr := os.Stat(filepath.Join(dir, "tailscaled.exe"))
|
|
||||||
if cliErr == nil && daemonErr == nil {
|
|
||||||
// Almost certainly MSI.
|
|
||||||
// We have tailscaled.exe and tailscale.exe
|
|
||||||
// next to each other in Program Files, but no
|
|
||||||
// uninstaller.
|
|
||||||
// TODO(bradfitz,dblohm7): tighter heuristic?
|
|
||||||
return "msi"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user