mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
clientupdate: remove TS_NOLAUNCH and GUI restart hacks from autoupdate
We've fixed the underlying issue in github.com/tailscale/corp/issues/13998. Fixes #10513 Signed-off-by: Aaron Klotz <aaron@tailscale.com>
This commit is contained in:
parent
646d17ac8d
commit
0f646937e9
@ -693,7 +693,6 @@ func (up *Updater) updateMacAppStore() error {
|
|||||||
var (
|
var (
|
||||||
verifyAuthenticode func(string) error // or nil on non-Windows
|
verifyAuthenticode func(string) error // or nil on non-Windows
|
||||||
markTempFileFunc func(string) error // or nil on non-Windows
|
markTempFileFunc func(string) error // or nil on non-Windows
|
||||||
launchTailscaleAsWinGUIUser func(string) error // or nil on non-Windows
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (up *Updater) updateWindows() error {
|
func (up *Updater) updateWindows() error {
|
||||||
@ -713,16 +712,6 @@ func (up *Updater) updateWindows() error {
|
|||||||
up.Logf("MSI install failed: %v", err)
|
up.Logf("MSI install failed: %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
up.Logf("relaunching tailscale-ipn.exe...")
|
|
||||||
exePath := os.Getenv(winExePathEnv)
|
|
||||||
if exePath == "" {
|
|
||||||
up.Logf("env var %q not passed to installer binary copy", winExePathEnv)
|
|
||||||
return fmt.Errorf("env var %q not passed to installer binary copy", winExePathEnv)
|
|
||||||
}
|
|
||||||
if err := launchTailscaleAsWinGUIUser(exePath); err != nil {
|
|
||||||
up.Logf("Failed to re-launch tailscale after update: %v", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
up.Logf("success.")
|
up.Logf("success.")
|
||||||
return nil
|
return nil
|
||||||
@ -820,9 +809,7 @@ func (up *Updater) switchOutputToFile() (io.Closer, error) {
|
|||||||
func (up *Updater) installMSI(msi string) error {
|
func (up *Updater) installMSI(msi string) error {
|
||||||
var err error
|
var err error
|
||||||
for tries := 0; tries < 2; tries++ {
|
for tries := 0; tries < 2; tries++ {
|
||||||
// TS_NOLAUNCH: don't automatically launch the app after install.
|
cmd := exec.Command("msiexec.exe", "/i", filepath.Base(msi), "/quiet", "/promptrestart", "/qn")
|
||||||
// We will launch it explicitly as the current GUI user afterwards.
|
|
||||||
cmd := exec.Command("msiexec.exe", "/i", filepath.Base(msi), "/quiet", "/promptrestart", "/qn", "TS_NOLAUNCH=true")
|
|
||||||
cmd.Dir = filepath.Dir(msi)
|
cmd.Dir = filepath.Dir(msi)
|
||||||
cmd.Stdout = up.Stdout
|
cmd.Stdout = up.Stdout
|
||||||
cmd.Stderr = up.Stderr
|
cmd.Stderr = up.Stderr
|
||||||
|
@ -7,14 +7,6 @@
|
|||||||
package clientupdate
|
package clientupdate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"os/exec"
|
|
||||||
"os/user"
|
|
||||||
"path/filepath"
|
|
||||||
"syscall"
|
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
"tailscale.com/util/winutil/authenticode"
|
"tailscale.com/util/winutil/authenticode"
|
||||||
)
|
)
|
||||||
@ -22,7 +14,6 @@
|
|||||||
func init() {
|
func init() {
|
||||||
markTempFileFunc = markTempFileWindows
|
markTempFileFunc = markTempFileWindows
|
||||||
verifyAuthenticode = verifyTailscale
|
verifyAuthenticode = verifyTailscale
|
||||||
launchTailscaleAsWinGUIUser = launchTailscaleAsGUIUser
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func markTempFileWindows(name string) error {
|
func markTempFileWindows(name string) error {
|
||||||
@ -35,50 +26,3 @@ func markTempFileWindows(name string) error {
|
|||||||
func verifyTailscale(path string) error {
|
func verifyTailscale(path string) error {
|
||||||
return authenticode.Verify(path, certSubjectTailscale)
|
return authenticode.Verify(path, certSubjectTailscale)
|
||||||
}
|
}
|
||||||
|
|
||||||
func launchTailscaleAsGUIUser(exePath string) error {
|
|
||||||
exePath = filepath.Join(filepath.Dir(exePath), "tailscale-ipn.exe")
|
|
||||||
|
|
||||||
var token windows.Token
|
|
||||||
if u, err := user.Current(); err == nil && u.Name == "SYSTEM" {
|
|
||||||
sessionID, err := wtsGetActiveSessionID()
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("wtsGetActiveSessionID(): %w", err)
|
|
||||||
}
|
|
||||||
if err := windows.WTSQueryUserToken(sessionID, &token); err != nil {
|
|
||||||
return fmt.Errorf("WTSQueryUserToken (0x%x): %w", sessionID, err)
|
|
||||||
}
|
|
||||||
defer token.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd := exec.Command(exePath)
|
|
||||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
|
||||||
Token: syscall.Token(token),
|
|
||||||
HideWindow: true,
|
|
||||||
}
|
|
||||||
return cmd.Start()
|
|
||||||
}
|
|
||||||
|
|
||||||
func wtsGetActiveSessionID() (uint32, error) {
|
|
||||||
var (
|
|
||||||
sessionInfo *windows.WTS_SESSION_INFO
|
|
||||||
count uint32 = 0
|
|
||||||
)
|
|
||||||
|
|
||||||
const WTS_CURRENT_SERVER_HANDLE = 0
|
|
||||||
if err := windows.WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE, 0, 1, &sessionInfo, &count); err != nil {
|
|
||||||
return 0, fmt.Errorf("WTSEnumerateSessions: %w", err)
|
|
||||||
}
|
|
||||||
defer windows.WTSFreeMemory(uintptr(unsafe.Pointer(sessionInfo)))
|
|
||||||
|
|
||||||
current := unsafe.Pointer(sessionInfo)
|
|
||||||
for i := uint32(0); i < count; i++ {
|
|
||||||
session := (*windows.WTS_SESSION_INFO)(current)
|
|
||||||
if session.State == windows.WTSActive {
|
|
||||||
return session.SessionID, nil
|
|
||||||
}
|
|
||||||
current = unsafe.Add(current, unsafe.Sizeof(windows.WTS_SESSION_INFO{}))
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0, errors.New("no active desktop sessions found")
|
|
||||||
}
|
|
||||||
|
@ -76,7 +76,7 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep
|
|||||||
tailscale.com/client/tailscale from tailscale.com/cmd/tailscale/cli+
|
tailscale.com/client/tailscale from tailscale.com/cmd/tailscale/cli+
|
||||||
tailscale.com/client/tailscale/apitype from tailscale.com/cmd/tailscale/cli+
|
tailscale.com/client/tailscale/apitype from tailscale.com/cmd/tailscale/cli+
|
||||||
tailscale.com/client/web from tailscale.com/cmd/tailscale/cli
|
tailscale.com/client/web from tailscale.com/cmd/tailscale/cli
|
||||||
💣 tailscale.com/clientupdate from tailscale.com/cmd/tailscale/cli+
|
tailscale.com/clientupdate from tailscale.com/cmd/tailscale/cli+
|
||||||
tailscale.com/clientupdate/distsign from tailscale.com/clientupdate
|
tailscale.com/clientupdate/distsign from tailscale.com/clientupdate
|
||||||
tailscale.com/cmd/tailscale/cli from tailscale.com/cmd/tailscale
|
tailscale.com/cmd/tailscale/cli from tailscale.com/cmd/tailscale
|
||||||
tailscale.com/control/controlbase from tailscale.com/control/controlhttp
|
tailscale.com/control/controlbase from tailscale.com/control/controlhttp
|
||||||
|
@ -228,7 +228,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
|||||||
tailscale.com/client/tailscale from tailscale.com/derp+
|
tailscale.com/client/tailscale from tailscale.com/derp+
|
||||||
tailscale.com/client/tailscale/apitype from tailscale.com/ipn/ipnlocal+
|
tailscale.com/client/tailscale/apitype from tailscale.com/ipn/ipnlocal+
|
||||||
tailscale.com/client/web from tailscale.com/ipn/ipnlocal
|
tailscale.com/client/web from tailscale.com/ipn/ipnlocal
|
||||||
💣 tailscale.com/clientupdate from tailscale.com/ipn/ipnlocal+
|
tailscale.com/clientupdate from tailscale.com/ipn/ipnlocal+
|
||||||
tailscale.com/clientupdate/distsign from tailscale.com/clientupdate
|
tailscale.com/clientupdate/distsign from tailscale.com/clientupdate
|
||||||
tailscale.com/cmd/tailscaled/childproc from tailscale.com/ssh/tailssh+
|
tailscale.com/cmd/tailscaled/childproc from tailscale.com/ssh/tailssh+
|
||||||
tailscale.com/control/controlbase from tailscale.com/control/controlclient+
|
tailscale.com/control/controlbase from tailscale.com/control/controlclient+
|
||||||
|
Loading…
Reference in New Issue
Block a user