logpolicy: on Windows, use tailscale-ipn log name if it already existed

For the migration to tailscaled.exe on Windows, don't create a new logid
if one existed under the old filename.

Updates #1232
This commit is contained in:
Brad Fitzpatrick 2021-02-05 10:53:15 -08:00
parent e8d4afedd1
commit 98f9e82c62
1 changed files with 12 additions and 0 deletions

View File

@ -339,6 +339,18 @@ func New(collection string) *Policy {
tryFixLogStateLocation(dir, cmdName)
cfgPath := filepath.Join(dir, fmt.Sprintf("%s.log.conf", cmdName))
// The Windows service previously ran as tailscale-ipn.exe, so
// let's keep using that log base name if it exists.
if runtime.GOOS == "windows" && cmdName == "tailscaled" {
const oldCmdName = "tailscale-ipn"
oldPath := filepath.Join(dir, oldCmdName+".log.conf")
if fi, err := os.Stat(oldPath); err == nil && fi.Mode().IsRegular() {
cfgPath = oldPath
cmdName = oldCmdName
}
}
var oldc *Config
data, err := ioutil.ReadFile(cfgPath)
if err != nil {