mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-01 14:05:39 +00:00
90fd04cbde
I realized that a lot of the problems that we're seeing around migration and LocalBackend state can be avoided if we drive Windows pref migration entirely from within tailscaled. By doing it this way, tailscaled can automatically perform the migration as soon as the connection with the client frontend is established. Since tailscaled is already running as LocalSystem, it already has access to the user's local AppData directory. The profile manager already knows which user is connected, so we simply need to resolve the user's prefs file and read it from there. Of course, to properly migrate this information we need to also check system policies. I moved a bunch of policy resolution code out of the GUI and into a new package in util/winutil/policy. Updates #7626 Signed-off-by: Aaron Klotz <aaron@tailscale.com>
38 lines
888 B
Go
38 lines
888 B
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
//go:build !windows
|
|
|
|
package ipnlocal
|
|
|
|
import (
|
|
"fmt"
|
|
"runtime"
|
|
|
|
"tailscale.com/ipn"
|
|
"tailscale.com/version"
|
|
)
|
|
|
|
func (pm *profileManager) loadLegacyPrefs() (string, ipn.PrefsView, error) {
|
|
k := ipn.LegacyGlobalDaemonStateKey
|
|
switch {
|
|
case runtime.GOOS == "ios":
|
|
k = "ipn-go-bridge"
|
|
case version.IsSandboxedMacOS():
|
|
k = "ipn-go-bridge"
|
|
case runtime.GOOS == "android":
|
|
k = "ipn-android"
|
|
}
|
|
prefs, err := pm.loadSavedPrefs(k)
|
|
if err != nil {
|
|
return "", ipn.PrefsView{}, fmt.Errorf("calling ReadState on state store: %w", err)
|
|
}
|
|
pm.logf("migrating %q profile to new format", k)
|
|
return "", prefs, nil
|
|
}
|
|
|
|
func (pm *profileManager) completeMigration(migrationSentinel string) {
|
|
// Do not delete the old state key, as we may be downgraded to an
|
|
// older version that still relies on it.
|
|
}
|