From 820952dabaf2ae2e59d8077e35b523b48a84c59b Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 21 Apr 2021 22:42:01 -0700 Subject: [PATCH] cmd/tailscale: don't print out old authURL on up --force-reauth Fixes #1671 Signed-off-by: Brad Fitzpatrick --- cmd/tailscale/cli/up.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/cmd/tailscale/cli/up.go b/cmd/tailscale/cli/up.go index dc2528486..6d1772922 100644 --- a/cmd/tailscale/cli/up.go +++ b/cmd/tailscale/cli/up.go @@ -245,6 +245,23 @@ func runUp(ctx context.Context, args []string) error { if err != nil { fatalf("can't fetch status from tailscaled: %v", err) } + origAuthURL := st.AuthURL + + // printAuthURL reports whether we should print out the + // provided auth URL from an IPN notify. + printAuthURL := func(url string) bool { + if upArgs.authKey != "" { + // Issue 1755: when using an authkey, don't + // show an authURL that might still be pending + // from a previous non-completed interactive + // login. + return false + } + if upArgs.forceReauth && url == origAuthURL { + return false + } + return true + } if distro.Get() == distro.Synology { notSupported := "not yet supported on Synology; see https://github.com/tailscale/tailscale/issues/451" @@ -367,7 +384,7 @@ func runUp(ctx context.Context, args []string) error { cancel() } } - if url := n.BrowseToURL; url != nil && upArgs.authKey == "" { + if url := n.BrowseToURL; url != nil && printAuthURL(*url) { printed = true fmt.Fprintf(os.Stderr, "\nTo authenticate, visit:\n\n\t%s\n\n", *url) }