diff --git a/config.go b/config.go index b7929fdd..1f04c0c4 100644 --- a/config.go +++ b/config.go @@ -18,7 +18,6 @@ package main import ( "os" - "os/user" "path/filepath" "runtime" "strings" @@ -93,9 +92,9 @@ func getMcConfigDir() (string, *probe.Error) { if mcCustomConfigDir != "" { return mcCustomConfigDir, nil } - u, err := user.Current() + u, err := userCurrent() if err != nil { - return "", probe.NewError(err) + return "", err.Trace() } // For windows the path is slightly different switch runtime.GOOS { diff --git a/utils.go b/utils.go index 99c5f544..ae353956 100644 --- a/utils.go +++ b/utils.go @@ -18,8 +18,14 @@ package main import ( "math/rand" + "os" + "os/user" "path/filepath" + "runtime" + "strconv" "time" + + "github.com/minio/minio-xl/pkg/probe" ) var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") @@ -39,3 +45,21 @@ func isBucketVirtualStyle(host string) bool { googleVirtual, _ := filepath.Match("*.storage.googleapis.com", host) return s3Virtual || googleVirtual } + +// user.Current is not implemented on 32bit, falling back and using a workaround instead. +func userCurrent() (*user.User, *probe.Error) { + if runtime.GOARCH == "386" && runtime.GOOS == "linux" { + return &user.User{ + Uid: strconv.Itoa(os.Getuid()), + Gid: strconv.Itoa(os.Getgid()), + Username: os.Getenv("USER"), + Name: os.Getenv("USER"), + HomeDir: os.Getenv("HOME"), + }, nil + } + user, err := user.Current() + if err != nil { + return nil, probe.NewError(err) + } + return user, nil +}