summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@tailscale.com>2020-07-30 07:47:19 -0700
committerBrad Fitzpatrick <bradfitz@tailscale.com>2020-07-30 07:47:19 -0700
commit6013462e9e0934cbc02907adcabe8a7068e13aec (patch)
tree21bf67a61272dd976395dc7a898ca81ed0051e98
parent60c00605d3061cff20f0d33bd677a86498021e7d (diff)
downloadtailscale-6013462e9e0934cbc02907adcabe8a7068e13aec.tar.xz
tailscale-6013462e9e0934cbc02907adcabe8a7068e13aec.zip
logpolicy: remove inaccurate comment, conditional tryFixLogStateLocation call
What I was probably actually hitting was exe caching issues where the binary was updated on a SMB shared drive and I tried to run it with the GUI exe still open, so Windows blends the two pages together and causes all sorts of random corruption. I didn't know about that at the time. Now, just call tryFixLogStateLocation unconditionally. The func itself will bail out early on non-applicable OSes. (And rearrange it to return even a bit earlier.)
-rw-r--r--logpolicy/logpolicy.go25
1 files changed, 12 insertions, 13 deletions
diff --git a/logpolicy/logpolicy.go b/logpolicy/logpolicy.go
index 90d9e864f..7708ebfbb 100644
--- a/logpolicy/logpolicy.go
+++ b/logpolicy/logpolicy.go
@@ -149,6 +149,14 @@ func runningUnderSystemd() bool {
// moved from whereever it does exist, into dir. Leftover logs state
// in / and $CACHE_DIRECTORY is deleted.
func tryFixLogStateLocation(dir, cmdname string) {
+ switch runtime.GOOS {
+ case "linux", "freebsd", "openbsd":
+ // These are the OSes where we might have written stuff into
+ // root. Others use different logic to find the logs storage
+ // dir.
+ default:
+ return
+ }
if cmdname == "" {
log.Printf("[unexpected] no cmdname given to tryFixLogStateLocation, please file a bug at https://github.com/tailscale/tailscale")
return
@@ -163,14 +171,6 @@ func tryFixLogStateLocation(dir, cmdname string) {
// Only root could have written log configs to weird places.
return
}
- switch runtime.GOOS {
- case "linux", "freebsd", "openbsd":
- // These are the OSes where we might have written stuff into
- // root. Others use different logic to find the logs storage
- // dir.
- default:
- return
- }
// We stored logs in 2 incorrect places: either /, or CACHE_DIR
// (aka /var/cache/tailscale). We want to move files into the
@@ -305,11 +305,10 @@ func New(collection string) *Policy {
dir := logsDir()
- if runtime.GOOS != "windows" { // version.CmdName call was blowing some Windows stack limit via goversion DLL loading
- tryFixLogStateLocation(dir, version.CmdName())
- }
+ cmdName := version.CmdName()
+ tryFixLogStateLocation(dir, cmdName)
- cfgPath := filepath.Join(dir, fmt.Sprintf("%s.log.conf", version.CmdName()))
+ cfgPath := filepath.Join(dir, fmt.Sprintf("%s.log.conf", cmdName))
var oldc *Config
data, err := ioutil.ReadFile(cfgPath)
if err != nil {
@@ -359,7 +358,7 @@ func New(collection string) *Policy {
HTTPC: &http.Client{Transport: newLogtailTransport(logtail.DefaultHost)},
}
- filchBuf, filchErr := filch.New(filepath.Join(dir, version.CmdName()), filch.Options{})
+ filchBuf, filchErr := filch.New(filepath.Join(dir, cmdName), filch.Options{})
if filchBuf != nil {
c.Buffer = filchBuf
}