clientupdate: check whether running as root early (#10161)

Check for root early, before we fetch the pkgs index. This avoids
several seconds delay for the command to tell you to sudo.

Updates #cleanup

Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
pull/10167/head
Andrew Lytvynov 7 months ago committed by GitHub
parent 9b158db2c6
commit 63062abadc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -260,6 +260,9 @@ func (up *Updater) updateSynology() error {
if up.Version != "" {
return errors.New("installing a specific version on Synology is not supported")
}
if err := requireRoot(); err != nil {
return err
}
// Get the latest version and list of SPKs from pkgs.tailscale.com.
dsmVersion := distro.DSMVersion()
@ -277,9 +280,6 @@ func (up *Updater) updateSynology() error {
return fmt.Errorf("cannot find Synology package for os=%s arch=%s, please report a bug with your device model", osName, arch)
}
if err := requireRoot(); err != nil {
return err
}
if !up.confirm(latest.SPKsVersion) {
return nil
}
@ -713,14 +713,6 @@ func (up *Updater) updateWindows() error {
up.Logf("success.")
return nil
}
ver, err := requestedTailscaleVersion(up.Version, up.track)
if err != nil {
return err
}
arch := runtime.GOARCH
if arch == "386" {
arch = "x86"
}
if !winutil.IsCurrentProcessElevated() {
return errors.New(`update must be run as Administrator
@ -730,6 +722,14 @@ you can run the command prompt as Administrator one of these ways:
* press Windows+x, then press a
* press Windows+r, type in "cmd", then press Ctrl+Shift+Enter`)
}
ver, err := requestedTailscaleVersion(up.Version, up.track)
if err != nil {
return err
}
arch := runtime.GOARCH
if arch == "386" {
arch = "x86"
}
if !up.confirm(ver) {
return nil
}
@ -946,14 +946,14 @@ func (up *Updater) updateFreeBSD() (err error) {
}
func (up *Updater) updateLinuxBinary() error {
ver, err := requestedTailscaleVersion(up.Version, up.track)
if err != nil {
return err
}
// Root is needed to overwrite binaries and restart systemd unit.
if err := requireRoot(); err != nil {
return err
}
ver, err := requestedTailscaleVersion(up.Version, up.track)
if err != nil {
return err
}
if !up.confirm(ver) {
return nil
}

Loading…
Cancel
Save