From 77127a24948687c6a22f521a0eb020a78c5ab187 Mon Sep 17 00:00:00 2001 From: Andrew Lytvynov Date: Tue, 17 Oct 2023 14:24:06 -0700 Subject: [PATCH] clientupdate: fix background install for linux tarballs (#9852) Two bug fixes: 1. when tailscale update is executed as root, `os.UserCacheDir` may return an error because `$XDG_CACHE_HOME` and `$HOME` are not set; fallback to `os.TempDir` in those cases 2. on some weird distros (like my EndeavourOS), `/usr/sbin` is just a symlink to `/usr/bin`; when we resolve `tailscale` binary path from `tailscaled`, allow `tailscaled` to be in either directory Updates #755 Signed-off-by: Andrew Lytvynov --- clientupdate/clientupdate.go | 2 +- ipn/ipnlocal/c2n.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/clientupdate/clientupdate.go b/clientupdate/clientupdate.go index b42d912a9..9f1bc441f 100644 --- a/clientupdate/clientupdate.go +++ b/clientupdate/clientupdate.go @@ -911,7 +911,7 @@ func (up *Updater) updateLinuxBinary() error { func (up *Updater) downloadLinuxTarball(ver string) (string, error) { dlDir, err := os.UserCacheDir() if err != nil { - return "", err + dlDir = os.TempDir() } dlDir = filepath.Join(dlDir, "tailscale-update") if err := os.MkdirAll(dlDir, 0700); err != nil { diff --git a/ipn/ipnlocal/c2n.go b/ipn/ipnlocal/c2n.go index e5510e2b9..d95c3e7cc 100644 --- a/ipn/ipnlocal/c2n.go +++ b/ipn/ipnlocal/c2n.go @@ -305,9 +305,12 @@ func findCmdTailscale() (string, error) { } switch runtime.GOOS { case "linux": - if self == "/usr/sbin/tailscaled" { + if self == "/usr/sbin/tailscaled" || self == "/usr/bin/tailscaled" { return "/usr/bin/tailscale", nil } + if self == "/usr/local/sbin/tailscaled" || self == "/usr/local/bin/tailscaled" { + return "/usr/local/bin/tailscale", nil + } return "", errors.New("tailscale not found in expected place") case "windows": dir := filepath.Dir(self)