From 1caad902cb1d8ee9baaad9d0b727d3d119e0c144 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 29 Mar 2017 08:55:33 -0700 Subject: [PATCH] config/path: Figure out absolute paths properly on windows. (#3996) The following form of arguments such as ``` minio.exe -C some_dir server dir ``` has stopped working because of lack of handling of absolute paths for config directory. Always calculate absolute path for any relative paths on any operating system. The following fix converts all config directory relative paths into absolute paths. Fixes #3991 --- cmd/server-main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/server-main.go b/cmd/server-main.go index 104806c68..939607d38 100644 --- a/cmd/server-main.go +++ b/cmd/server-main.go @@ -23,6 +23,7 @@ import ( "net/url" "os" "path" + "path/filepath" "sort" "strconv" "strings" @@ -482,6 +483,14 @@ func serverMain(c *cli.Context) { fatalIf(errors.New("empty directory"), "Configuration directory cannot be empty.") } + // Disallow relative paths, figure out absolute paths. + { + configDirAbs, err := filepath.Abs(configDir) + fatalIf(err, "Unable to fetch absolute path for config directory %s", configDir) + + configDir = configDirAbs + } + // Set configuration directory. setConfigDir(configDir)