@ -37,14 +37,16 @@ type safesocketDarwin struct {
sameuserproofFD * os . File // file descriptor for macos app store sameuserproof file
sameuserproofFD * os . File // file descriptor for macos app store sameuserproof file
sharedDir string // shared directory for location of sameuserproof file
sharedDir string // shared directory for location of sameuserproof file
checkConn bool // Check macsys safesocket port before returning it
checkConn bool // Check macsys safesocket port before returning it
isMacSysExt func ( ) bool // For testing only to force macsys
isMacSysExt func ( ) bool // For testing only to force macsys
isSandboxedMacos func ( ) bool // For testing only to force macOS sandbox
}
}
var ssd = safesocketDarwin {
var ssd = safesocketDarwin {
isMacSysExt : version . IsMacSysExt ,
isMacSysExt : version . IsMacSysExt ,
checkConn : true ,
isSandboxedMacos : version . IsSandboxedMacOS ,
sharedDir : "/Library/Tailscale" ,
checkConn : true ,
sharedDir : "/Library/Tailscale" ,
}
}
// There are three ways a Darwin binary can be run: as the Mac App Store (macOS)
// There are three ways a Darwin binary can be run: as the Mac App Store (macOS)
@ -66,6 +68,10 @@ func localTCPPortAndTokenDarwin() (port int, token string, err error) {
ssd . mu . Lock ( )
ssd . mu . Lock ( )
defer ssd . mu . Unlock ( )
defer ssd . mu . Unlock ( )
if ! ssd . isSandboxedMacos ( ) {
return 0 , "" , ErrNoTokenOnOS
}
if ssd . port != 0 && ssd . token != "" {
if ssd . port != 0 && ssd . token != "" {
return ssd . port , ssd . token , nil
return ssd . port , ssd . token , nil
}
}