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
pull/1280/head
Brad Fitzpatrick 3 years ago
parent e8d4afedd1
commit 98f9e82c62

@ -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 {

Loading…
Cancel
Save