paths: use /var/db for state on BSDs, and /var/run for sockets.

On BSD, /var/db is what linux calls /var/lib.

On modern linux, /run and /var/run are the same directory, but
on BSD the correct path is /var/run, so use that.

Fixes #79

Signed-off-by: David Anderson <dave@natulte.net>
This commit is contained in:
David Anderson
2020-03-03 17:37:37 -08:00
committed by Dave Anderson
parent 20da44eae3
commit dbc99dc0d2
2 changed files with 21 additions and 6 deletions

View File

@@ -21,8 +21,8 @@ func DefaultTailscaledSocket() string {
if runtime.GOOS == "windows" {
return ""
}
if fi, err := os.Stat("/run"); err == nil && fi.IsDir() {
return "/run/tailscale/tailscaled.sock"
if fi, err := os.Stat("/var/run"); err == nil && fi.IsDir() {
return "/var/run/tailscale/tailscaled.sock"
}
return "tailscaled.sock"
}