clientupdate: change Mac App Store support (#9891)

In the sandboxed app from the app store, we cannot check
`/Library/Preferences/com.apple.commerce.plist` or run `softwareupdate`.
We can at most print a helpful message and open the app store page.

Also, reenable macsys update function to mark it as supporting c2n
updates. macsys support in `tailscale update` was fixed.

Updates #755

Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
This commit is contained in:
Andrew Lytvynov
2023-10-20 08:58:41 -07:00
committed by GitHub
parent eced054796
commit 70f9c8a6ed
4 changed files with 38 additions and 157 deletions

View File

@@ -47,19 +47,7 @@ var isSandboxedMacOS lazy.SyncValue[bool]
// and macsys (System Extension) version on macOS, and false for
// tailscaled-on-macOS.
func IsSandboxedMacOS() bool {
if runtime.GOOS != "darwin" {
return false
}
return isSandboxedMacOS.Get(func() bool {
if IsMacSysExt() {
return true
}
exe, err := os.Executable()
if err != nil {
return false
}
return filepath.Base(exe) == "io.tailscale.ipn.macsys.network-extension" || strings.HasSuffix(exe, "/Contents/MacOS/Tailscale") || strings.HasSuffix(exe, "/Contents/MacOS/IPNExtension")
})
return IsMacAppStore() || IsMacSysExt()
}
var isMacSysExt lazy.SyncValue[bool]
@@ -79,6 +67,23 @@ func IsMacSysExt() bool {
})
}
var isMacAppStore lazy.SyncValue[bool]
// IsMacAppStore whether this binary is from the App Store version of Tailscale
// for macOS.
func IsMacAppStore() bool {
if runtime.GOOS != "darwin" {
return false
}
return isMacAppStore.Get(func() bool {
exe, err := os.Executable()
if err != nil {
return false
}
return strings.HasSuffix(exe, "/Contents/MacOS/Tailscale") || strings.HasSuffix(exe, "/Contents/MacOS/IPNExtension")
})
}
var isAppleTV lazy.SyncValue[bool]
// IsAppleTV reports whether this binary is part of the Tailscale network extension for tvOS.