mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-16 11:41:39 +00:00
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.)
This commit is contained in:
parent
60c00605d3
commit
6013462e9e
@ -149,6 +149,14 @@ func runningUnderSystemd() bool {
|
|||||||
// moved from whereever it does exist, into dir. Leftover logs state
|
// moved from whereever it does exist, into dir. Leftover logs state
|
||||||
// in / and $CACHE_DIRECTORY is deleted.
|
// in / and $CACHE_DIRECTORY is deleted.
|
||||||
func tryFixLogStateLocation(dir, cmdname string) {
|
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 == "" {
|
if cmdname == "" {
|
||||||
log.Printf("[unexpected] no cmdname given to tryFixLogStateLocation, please file a bug at https://github.com/tailscale/tailscale")
|
log.Printf("[unexpected] no cmdname given to tryFixLogStateLocation, please file a bug at https://github.com/tailscale/tailscale")
|
||||||
return
|
return
|
||||||
@ -163,14 +171,6 @@ func tryFixLogStateLocation(dir, cmdname string) {
|
|||||||
// Only root could have written log configs to weird places.
|
// Only root could have written log configs to weird places.
|
||||||
return
|
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
|
// We stored logs in 2 incorrect places: either /, or CACHE_DIR
|
||||||
// (aka /var/cache/tailscale). We want to move files into the
|
// (aka /var/cache/tailscale). We want to move files into the
|
||||||
@ -305,11 +305,10 @@ func New(collection string) *Policy {
|
|||||||
|
|
||||||
dir := logsDir()
|
dir := logsDir()
|
||||||
|
|
||||||
if runtime.GOOS != "windows" { // version.CmdName call was blowing some Windows stack limit via goversion DLL loading
|
cmdName := version.CmdName()
|
||||||
tryFixLogStateLocation(dir, 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
|
var oldc *Config
|
||||||
data, err := ioutil.ReadFile(cfgPath)
|
data, err := ioutil.ReadFile(cfgPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -359,7 +358,7 @@ func New(collection string) *Policy {
|
|||||||
HTTPC: &http.Client{Transport: newLogtailTransport(logtail.DefaultHost)},
|
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 {
|
if filchBuf != nil {
|
||||||
c.Buffer = filchBuf
|
c.Buffer = filchBuf
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user