diff --git a/ipn/ipnserver/server.go b/ipn/ipnserver/server.go index 2b0943f25..6cd81e517 100644 --- a/ipn/ipnserver/server.go +++ b/ipn/ipnserver/server.go @@ -20,7 +20,6 @@ import ( "os/exec" "os/signal" "os/user" - "path/filepath" "runtime" "strconv" "strings" @@ -602,7 +601,7 @@ func tryWindowsAppDataMigration(logf logger.Logf, path string) string { // what they are doing. return path } - oldFile := filepath.Join(os.Getenv("LocalAppData"), "Tailscale", "server-state.conf") + oldFile := paths.LegacyStateFilePath() return paths.TryConfigFileMigration(logf, oldFile, path) } diff --git a/paths/paths_unix.go b/paths/paths_unix.go index 9c0116bc3..fa95c783e 100644 --- a/paths/paths_unix.go +++ b/paths/paths_unix.go @@ -81,3 +81,8 @@ func ensureStateDirPerms(dir string) error { } return os.Chmod(dir, perm) } + +// LegacyStateFilePath is not applicable to UNIX; it is just stubbed out. +func LegacyStateFilePath() string { + return "" +} diff --git a/paths/paths_windows.go b/paths/paths_windows.go index e00a8062a..f1b34b633 100644 --- a/paths/paths_windows.go +++ b/paths/paths_windows.go @@ -148,3 +148,9 @@ func ensureStateDirPerms(dirPath string) error { return windows.SetNamedSecurityInfo(dirPath, windows.SE_FILE_OBJECT, flags, sids.User, sids.PrimaryGroup, dacl, nil) } + +// LegacyStateFilePath returns the legacy path to the state file when it was stored under the +// current user's %LocalAppData%. +func LegacyStateFilePath() string { + return filepath.Join(os.Getenv("LocalAppData"), "Tailscale", "server-state.conf") +}