From 4512aad8891bf412d827ba3fffef21b015672e03 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 28 Apr 2021 08:34:13 -0700 Subject: [PATCH] version: add IsSandboxedMacOS func For when we need to tweak behavior or errors as a function of which of 3 macOS Tailscale variants we're using. (more accessors coming later as needed) Signed-off-by: Brad Fitzpatrick --- version/prop.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/version/prop.go b/version/prop.go index b4565d247..a18080518 100644 --- a/version/prop.go +++ b/version/prop.go @@ -4,7 +4,11 @@ package version -import "runtime" +import ( + "os" + "runtime" + "strings" +) // IsMobile reports whether this is a mobile client build. func IsMobile() bool { @@ -22,3 +26,14 @@ func OS() string { } return runtime.GOOS } + +// IsSandboxedMacOS reports whether this process is a sandboxed macOS +// (GUI) process. It is true for the Mac App Store and macsys (System +// Extension) version on macOS, and false for tailscaled-on-macOS. +func IsSandboxedMacOS() bool { + if runtime.GOOS != "darwin" { + return false + } + exe, _ := os.Executable() + return strings.HasSuffix(exe, "/Contents/MacOS/Tailscale") +}