386: Support 'mc' for linux 32bit operating systems
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user