diff --git a/cmd/tailscaled/tailscaled.go b/cmd/tailscaled/tailscaled.go index fa26ab4d7..814ca2596 100644 --- a/cmd/tailscaled/tailscaled.go +++ b/cmd/tailscaled/tailscaled.go @@ -158,13 +158,12 @@ func main() { } } - if beWindowsSubprocess() { - return - } - flag.Parse() if flag.NArg() > 0 { - log.Fatalf("tailscaled does not take non-flag arguments: %q", flag.Args()) + // Windows subprocess is spawned with /subprocess, so we need to avoid this check there. + if runtime.GOOS != "windows" || flag.Arg(0) != "/subproc" { + log.Fatalf("tailscaled does not take non-flag arguments: %q", flag.Args()) + } } if printVersion { @@ -193,6 +192,10 @@ func main() { args.statepath = paths.DefaultTailscaledStateFile() } + if beWindowsSubprocess() { + return + } + err := run() // Remove file sharing from Windows shell (noop in non-windows) diff --git a/cmd/tailscaled/tailscaled_windows.go b/cmd/tailscaled/tailscaled_windows.go index db54bfcb6..2e0d7cf2b 100644 --- a/cmd/tailscaled/tailscaled_windows.go +++ b/cmd/tailscaled/tailscaled_windows.go @@ -260,7 +260,7 @@ func startIPNServer(ctx context.Context, logid string) error { linkMon, err := monitor.New(logf) if err != nil { - return err + return fmt.Errorf("monitor: %w", err) } dialer := new(tsdial.Dialer) @@ -367,7 +367,7 @@ type engineOrError struct { } store, err := store.New(logf, statePathOrDefault()) if err != nil { - return err + return fmt.Errorf("store: %w", err) } ln, _, err := safesocket.Listen(args.socketpath, safesocket.WindowsLocalPort)