From 9d701c704416a1d8648dd2818a8a15c4da99b424 Mon Sep 17 00:00:00 2001 From: Jesse Hallam Date: Wed, 21 Mar 2018 14:27:14 -0400 Subject: Fix various segfaults when running `go test` manually (#8448) * failing to find i18n shouldn't segfault The server was trying to handle the fact that it couldn't find the i18n directory, by emitting a translated log message... * fix utils.FindDir The attempts to find the directory in the parent or grandparent directory don't work if the current working directory was inside `enterprise`, with `enterprise` itself being a symlink as per the usual developer setup. Recurse to the root of the filesystem, cleaning the path along the way to work around this limitation (and allow tests to be run from an arbitrarily deep nesting level.) Fix corresponding usages to employ filepath.Join. * failing to find html templates shouldn't segfault * fail fast if the test user cannot be created * rework utils.FindDir to retain backwards compatibility --- api4/oauth.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'api4/oauth.go') diff --git a/api4/oauth.go b/api4/oauth.go index d0f43256a..a173159b6 100644 --- a/api4/oauth.go +++ b/api4/oauth.go @@ -6,6 +6,7 @@ package api4 import ( "net/http" "net/url" + "path/filepath" "strings" l4g "github.com/alecthomas/log4go" @@ -375,7 +376,7 @@ func authorizeOAuthPage(c *Context, w http.ResponseWriter, r *http.Request) { w.Header().Set("Cache-Control", "no-cache, max-age=31556926, public") staticDir, _ := utils.FindDir(model.CLIENT_DIR) - http.ServeFile(w, r, staticDir+"root.html") + http.ServeFile(w, r, filepath.Join(staticDir, "root.html")) } func getAccessToken(c *Context, w http.ResponseWriter, r *http.Request) { -- cgit v1.2.3-1-g7c22