From c7ab41a3b0bb21575dd5e896116f3b193b57165a Mon Sep 17 00:00:00 2001 From: Alexey Gusev Date: Fri, 5 Mar 2021 23:40:41 +0300 Subject: [PATCH] Fix token storage path --- user/files.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/user/files.go b/user/files.go index 3235497..a4fa7a0 100644 --- a/user/files.go +++ b/user/files.go @@ -4,6 +4,7 @@ import ( "encoding/json" "io/ioutil" "log" + "strings" "os" "github.com/adrg/xdg" @@ -62,10 +63,10 @@ func readTokensToUsers() { func tokenStoragePath() string { dir, err := xdg.DataFile("mycorrhiza/tokens.json") if err != nil { - // Yes, it is unix-only, but function above rarely fails, so this block is probably never reached. - path := "/home/" + os.Getenv("HOME") + "/.local/share/mycorrhiza/tokens.json" - os.MkdirAll(path, 0777) - return path + log.Fatal(err) + } + if strings.HasPrefix(dir, util.WikiDir) { + log.Fatal("Error: Wiki storage directory includes private config files") } return dir }