mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-03 02:21:58 +00:00
net/dns: do not run wsl.exe as LocalSystem
It doesn't work. It needs to run as the user. https://github.com/microsoft/WSL/issues/4803 The mechanism for doing this was extracted from: https://web.archive.org/web/20101009012531/http://blogs.msdn.com/b/winsdk/archive/2009/07/14/launching-an-interactive-process-from-windows-service-in-windows-vista-and-later.aspx While here, we also reclaculate WSL distro set on SetDNS. This accounts for: 1. potential inability to access wsl.exe on startup 2. WSL being installed while Tailscale is running 3. A new WSL distrobution being installed Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
This commit is contained in:
committed by
David Crawshaw
parent
6f3a5802a6
commit
6b9f8208f4
@@ -43,9 +43,10 @@ type windowsManager struct {
|
||||
|
||||
func NewOSConfigurator(logf logger.Logf, interfaceName string) (OSConfigurator, error) {
|
||||
ret := windowsManager{
|
||||
logf: logf,
|
||||
guid: interfaceName,
|
||||
nrptWorks: isWindows10OrBetter(),
|
||||
logf: logf,
|
||||
guid: interfaceName,
|
||||
nrptWorks: isWindows10OrBetter(),
|
||||
wslManager: newWSLManager(logf),
|
||||
}
|
||||
|
||||
// Best-effort: if our NRPT rule exists, try to delete it. Unlike
|
||||
@@ -58,9 +59,11 @@ func NewOSConfigurator(logf logger.Logf, interfaceName string) (OSConfigurator,
|
||||
ret.delKey(nrptBase)
|
||||
}
|
||||
|
||||
if distros := wslDistros(logf); len(distros) > 0 {
|
||||
logf("WSL distributions: %v", distros)
|
||||
ret.wslManager = newWSLManager(logf, distros)
|
||||
// Log WSL status once at startup.
|
||||
if distros, err := wslDistros(); err != nil {
|
||||
logf("WSL: could not list distributions: %v", err)
|
||||
} else {
|
||||
logf("WSL: found %d distributions", len(distros))
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
@@ -305,12 +308,10 @@ func (m windowsManager) SetDNS(cfg OSConfig) error {
|
||||
// On initial setup of WSL, the restart caused by --shutdown is slow,
|
||||
// so we do it out-of-line.
|
||||
go func() {
|
||||
if m.wslManager != nil {
|
||||
if err := m.wslManager.SetDNS(cfg); err != nil {
|
||||
m.logf("WSL SetDNS: %v", err) // continue
|
||||
} else {
|
||||
m.logf("WSL SetDNS: success")
|
||||
}
|
||||
if err := m.wslManager.SetDNS(cfg); err != nil {
|
||||
m.logf("WSL SetDNS: %v", err) // continue
|
||||
} else {
|
||||
m.logf("WSL SetDNS: success")
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user