tsnet: fall back to 'tsnet' when os.Executable fails on darwin

Updates #19050

When tsnet.Server.start() is called with both Hostname and Dir explicitly
set, os.Executable() failure should not prevent the server from starting.
Extend the existing ios fallback to also cover darwin, where the same
failure occurs when the Go runtime is embedded in a framework launched
via Xcode's debug launcher.

Signed-off-by: Prakash Rudraraju <prakashrj@yahoo.com>
This commit is contained in:
Prakash Rudraraju
2026-03-19 17:32:35 +00:00
committed by Brad Fitzpatrick
parent ea7040eea2
commit 931fe56586

View File

@@ -618,10 +618,15 @@ func (s *Server) start() (reterr error) {
// directory and hostname when they're not supplied. But we can fall
// back to "tsnet" as well.
exe = "tsnet"
case "ios":
case "ios", "darwin":
// When compiled as a framework (via TailscaleKit in libtailscale),
// os.Executable() returns an error, so fall back to "tsnet" there
// too.
// os.Executable() returns an error on iOS. The same failure occurs
// on macOS (darwin) when the framework is loaded in a process
// launched by a debugger or certain host environments (e.g. Xcode),
// where the OS does not expose a resolvable executable path to the
// embedded Go runtime. Fall back to "tsnet" in both cases — the
// value is only used as a default hostname/directory when neither
// Server.Hostname nor Server.Dir is set.
exe = "tsnet"
default:
return err