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
This commit is contained in:
Harshavardhana 2017-03-29 08:55:33 -07:00 committed by GitHub
parent d99efa2c93
commit 1caad902cb

View File

@ -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)