summaryrefslogtreecommitdiffhomepage
path: root/version
diff options
context:
space:
mode:
authorAvery Pennarun <apenwarr@tailscale.com>2020-07-30 02:59:06 -0400
committerAvery Pennarun <apenwarr@tailscale.com>2020-07-30 04:52:20 -0400
commitf81233524fddeec450940af8dc1a0dd8841bf28c (patch)
treef2238d9b934880d1749b30b57707f86606fefd98 /version
parent2ce2b632396801600b057859ae26c4b508f10e57 (diff)
downloadtailscale-1.1.0.tar.xz
tailscale-1.1.0.zip
version/cmdname: s/path/filepath/ and fix version.ReadExe() fallback.v1.1.0
We were using the Go 'path' module, which apparently doesn't handle backslashes correctly. path/filepath does. However, the main bug turned out to be that we were not calling .Base() on the path if version.ReadExe() fails, which it seems to do at least on Windows 7. As a result, our logfile persistence was not working on Windows, and logids would be regenerated on every restart. Affects: #620 Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
Diffstat (limited to 'version')
-rw-r--r--version/cmdname.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/version/cmdname.go b/version/cmdname.go
index 4e5280aff..a72eb9c21 100644
--- a/version/cmdname.go
+++ b/version/cmdname.go
@@ -8,7 +8,7 @@ package version
import (
"os"
- "path"
+ "path/filepath"
"strings"
"rsc.io/goversion/version"
@@ -26,12 +26,13 @@ func CmdName() string {
v, err := version.ReadExe(e)
if err != nil {
ret = strings.TrimSuffix(strings.ToLower(e), ".exe")
+ ret = filepath.Base(ret)
} else {
// v is like:
// "path\ttailscale.com/cmd/tailscale\nmod\ttailscale.com\t(devel)\t\ndep\tgithub.com/apenwarr/fixconsole\tv0.0.0-20191012055117-5a9f6489cc29\th1:muXWUcay7DDy1/hEQWrYlBy+g0EuwT70sBHg65SeUc4=\ndep\tgithub....
for _, line := range strings.Split(v.ModuleInfo, "\n") {
if strings.HasPrefix(line, "path\t") {
- ret = path.Base(strings.TrimPrefix(line, "path\t"))
+ ret = filepath.Base(strings.TrimPrefix(line, "path\t"))
break
}
}