logpolicy: don't use C:\ProgramData use for tailscale-ipn GUI's log dir

tailscale-ipn.exe (the GUI) shouldn't use C:\ProgramData.

Also, migrate the earlier misnamed wg32/wg64 conf files if they're present.
(That was stopped in 2db877caa3, but the
files exist from fresh 1.14 installs)

Updates #2856

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2021-09-20 15:57:06 -07:00
committed by Brad Fitzpatrick
parent 2db877caa3
commit 7d8227e7a6
3 changed files with 90 additions and 40 deletions

View File

@@ -5,9 +5,10 @@
package paths
import (
"log"
"os"
"path/filepath"
"tailscale.com/types/logger"
)
// TryConfigFileMigration carefully copies the contents of oldFile to
@@ -17,14 +18,14 @@ import (
// default config to be written to.
// - if oldFile exists but copying to newFile fails, return oldFile so
// there will at least be some config to work with.
func TryConfigFileMigration(oldFile, newFile string) string {
func TryConfigFileMigration(logf logger.Logf, oldFile, newFile string) string {
_, err := os.Stat(newFile)
if err == nil {
// Common case for a system which has already been migrated.
return newFile
}
if !os.IsNotExist(err) {
log.Printf("TryConfigFileMigration failed; new file: %v", err)
logf("TryConfigFileMigration failed; new file: %v", err)
return newFile
}
@@ -39,15 +40,15 @@ func TryConfigFileMigration(oldFile, newFile string) string {
if err != nil {
removeErr := os.Remove(newFile)
if removeErr != nil {
log.Printf("TryConfigFileMigration failed; write newFile no cleanup: %v, remove err: %v",
logf("TryConfigFileMigration failed; write newFile no cleanup: %v, remove err: %v",
err, removeErr)
return oldFile
}
log.Printf("TryConfigFileMigration failed; write newFile: %v", err)
logf("TryConfigFileMigration failed; write newFile: %v", err)
return oldFile
}
log.Printf("TryConfigFileMigration: successfully migrated: from %v to %v",
logf("TryConfigFileMigration: successfully migrated: from %v to %v",
oldFile, newFile)
return newFile