diff options
| author | Percy Wegmann <percy@tailscale.com> | 2025-09-04 06:36:52 -0500 |
|---|---|---|
| committer | Percy Wegmann <percy@tailscale.com> | 2025-09-04 06:37:47 -0500 |
| commit | 9fe21bb382484df1c3b109e92d292eaa5144102d (patch) | |
| tree | eecebf1fbb21dfdf4be7d51eb9903ed555989a28 | |
| parent | d8ac539bf9617bc18cd2c5f231c77b1edb48849e (diff) | |
| download | tailscale-percy/oss14025.tar.xz tailscale-percy/oss14025.zip | |
cmd/tailscaled: actually derive statedir from statepathpercy/oss14025
The documentation for `--statedir` says that if unspecified, it will be derived
from `--state` if possible. It was not. In addition, if `--state` was specified,
`--statedir` was not even defaulted to its usual default, so remained empty.
Now, if only `--state` is specified, `--statedir` is derived from it.
Updates #14025
Signed-off-by: Percy Wegmann <percy@tailscale.com>
| -rw-r--r-- | cmd/tailscaled/tailscaled.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/cmd/tailscaled/tailscaled.go b/cmd/tailscaled/tailscaled.go index ddf6d9ef6..cb8c09bf5 100644 --- a/cmd/tailscaled/tailscaled.go +++ b/cmd/tailscaled/tailscaled.go @@ -255,9 +255,9 @@ func main() { log.Fatalf("--bird-socket is not supported on %s", runtime.GOOS) } - // Only apply a default statepath when neither have been provided, so that a - // user may specify only --statedir if they wish. if args.statepath == "" && args.statedir == "" { + // Only apply a default statepath when neither have been provided, so that a + // user may specify only --statedir if they wish. if paths.MakeAutomaticStateDir() { d := paths.DefaultTailscaledStateDir() if d != "" { @@ -269,6 +269,9 @@ func main() { } else { args.statepath = paths.DefaultTailscaledStateFile() } + } else if args.statedir == "" && args.statepath != "" { + // When only a statepath is specified, derive statedir from statepath. + args.statedir = filepath.Dir(args.statepath) } if args.encryptState { |
