mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-20 11:58:39 +00:00
safesocket: actually fix CLI on macsys build
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
ec2249b6f2
commit
82117f7a63
@ -22,12 +22,14 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// localTCPPortAndTokenMacsys returns the localhost TCP port number and auth token
|
// localTCPPortAndTokenMacsys returns the localhost TCP port number and auth token
|
||||||
// from the directory dir, if dir is for the "macsys" variant.
|
// from /Library/Tailscale.
|
||||||
//
|
//
|
||||||
// In that case the files are:
|
// In that case the files are:
|
||||||
// /Library/Tailscale/ipnport => $port (symlink with localhost port number target)
|
// /Library/Tailscale/ipnport => $port (symlink with localhost port number target)
|
||||||
// /Library/Tailscale/sameuserproof-$port is a file with auth
|
// /Library/Tailscale/sameuserproof-$port is a file with auth
|
||||||
func localTCPPortAndTokenMacsys(dir string) (port int, token string, err error) {
|
func localTCPPortAndTokenMacsys() (port int, token string, err error) {
|
||||||
|
|
||||||
|
const dir = "/Library/Tailscale"
|
||||||
portStr, err := os.Readlink(filepath.Join(dir, "ipnport"))
|
portStr, err := os.Readlink(filepath.Join(dir, "ipnport"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, "", err
|
return 0, "", err
|
||||||
@ -55,8 +57,10 @@ func localTCPPortAndTokenDarwin() (port int, token string, err error) {
|
|||||||
|
|
||||||
if dir := os.Getenv("TS_MACOS_CLI_SHARED_DIR"); dir != "" {
|
if dir := os.Getenv("TS_MACOS_CLI_SHARED_DIR"); dir != "" {
|
||||||
// First see if we're running as the non-AppStore "macsys" variant.
|
// First see if we're running as the non-AppStore "macsys" variant.
|
||||||
if port, token, err := localTCPPortAndTokenMacsys(dir); err == nil {
|
if strings.Contains(os.Getenv("HOME"), "/Containers/io.tailscale.ipn.macsys/") {
|
||||||
return port, token, nil
|
if port, token, err := localTCPPortAndTokenMacsys(); err == nil {
|
||||||
|
return port, token, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The current binary (this process) is sandboxed. The user is
|
// The current binary (this process) is sandboxed. The user is
|
||||||
@ -96,7 +100,7 @@ func localTCPPortAndTokenDarwin() (port int, token string, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
// Before returning an error, see if we're running the
|
// Before returning an error, see if we're running the
|
||||||
// macsys variant at the normal location.
|
// macsys variant at the normal location.
|
||||||
if port, token, err := localTCPPortAndTokenMacsys("/Library/Tailscale"); err == nil {
|
if port, token, err := localTCPPortAndTokenMacsys(); err == nil {
|
||||||
return port, token, nil
|
return port, token, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +128,7 @@ func localTCPPortAndTokenDarwin() (port int, token string, err error) {
|
|||||||
|
|
||||||
// Before returning an error, see if we're running the
|
// Before returning an error, see if we're running the
|
||||||
// macsys variant at the normal location.
|
// macsys variant at the normal location.
|
||||||
if port, token, err := localTCPPortAndTokenMacsys("/Library/Tailscale"); err == nil {
|
if port, token, err := localTCPPortAndTokenMacsys(); err == nil {
|
||||||
return port, token, nil
|
return port, token, nil
|
||||||
}
|
}
|
||||||
return 0, "", ErrTokenNotFound
|
return 0, "", ErrTokenNotFound
|
||||||
|
Loading…
x
Reference in New Issue
Block a user