Skip to content

Commit b29d58a

Browse files
committed
fix: change default path
1 parent 872b762 commit b29d58a

File tree

4 files changed

+32
-14
lines changed

4 files changed

+32
-14
lines changed

logpolicy/logpolicy.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"sync"
2929
"time"
3030

31-
"golang.org/x/sys/unix"
3231
"golang.org/x/term"
3332
"tailscale.com/atomicfile"
3433
"tailscale.com/envknob"
@@ -254,14 +253,15 @@ func LogsDir(logf logger.Logf) string {
254253
}
255254

256255
cacheDir, err := os.UserCacheDir()
257-
if _, exists := os.LookupEnv("ANDROID_DATA"); exists {
258-
if tmp := os.TempDir(); tmp != "" {
259-
if err := unix.Access(tmp, unix.W_OK); err == nil {
260-
cacheDir = tmp
261-
} else {
262-
logf("logpolicy: temp directory %q is not writable: %v", tmp, err)
256+
if runtime.GOOS == "android" {
257+
prefix := os.Getenv("PREFIX")
258+
if prefix == "" {
259+
if os.Geteuid() == 0 {
260+
return filepath.Join("data", "adb", "tailscale", "log")
263261
}
262+
return filepath.Join(os.TempDir(), "tailscale", "log")
264263
}
264+
return filepath.Join(prefix, "var", "log", "tailscale")
265265
}
266266
if err == nil {
267267
d := filepath.Join(cacheDir, "Tailscale")

paths/paths.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@ var AppSharedDir syncs.AtomicValue[string]
2323
// or the empty string if there's no reasonable default.
2424
func DefaultTailscaledSocket() string {
2525
if runtime.GOOS == "android" {
26-
if os.Geteuid() == 0 {
27-
if fi, err := os.Stat("/data/adb/tailscale"); err == nil && fi.IsDir() {
28-
return "/data/adb/tailscale/tailscaled.sock"
26+
prefix := os.Getenv("PREFIX")
27+
if prefix == "" {
28+
if os.Geteuid() == 0 {
29+
return filepath.Join("data", "adb", "tailscale", "tmp", "tailscaled.sock")
2930
}
31+
return filepath.Join(os.TempDir(), "tailscale", "tailscaled.sock")
3032
}
31-
if wd, err := os.Getwd(); err == nil {
32-
return filepath.Join(wd, "tailscaled.sock")
33-
}
34-
return filepath.Join(os.TempDir(), "tailscaled.sock")
33+
return filepath.Join(prefix, "var", "run", "tailscaled.sock")
3534
}
3635
if runtime.GOOS == "windows" {
3736
return `\\.\pipe\ProtectedPrefix\Administrators\Tailscale\tailscaled`

paths/paths_unix.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ func statePath() string {
3333
return "/Library/Tailscale/tailscaled.state"
3434
case "aix":
3535
return "/var/tailscale/tailscaled.state"
36+
case "android":
37+
prefix := os.Getenv("PREFIX")
38+
if prefix == "" {
39+
if os.Geteuid() == 0 {
40+
return filepath.Join("data", "adb", "tailscale", "tmp", "tailscaled.state")
41+
}
42+
return filepath.Join(os.TempDir(), "tailscale", "tailscaled.state")
43+
}
44+
return filepath.Join(prefix, "var", "lib", "tailscale", "tailscaled.state")
3645
default:
3746
return ""
3847
}

tsweb/tsweb.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ import (
4040
var DevMode bool
4141

4242
func DefaultCertDir(leafDir string) string {
43+
if runtime.GOOS == "android" {
44+
prefix := os.Getenv("PREFIX")
45+
if prefix == "" {
46+
if os.Geteuid() == 0 {
47+
return filepath.Join("data", "adb", "tailscale", "certs")
48+
}
49+
return filepath.Join(os.TempDir(), "tailscale", "certs")
50+
}
51+
return filepath.Join(prefix, "var", "lib", "tailscale", "certs")
52+
}
4353
cacheDir, err := os.UserCacheDir()
4454
if err == nil {
4555
return filepath.Join(cacheDir, "tailscale", leafDir)

0 commit comments

Comments
 (0)