mirror of https://github.com/minio/minio.git

19 changed files with 149 additions and 202 deletions
-
4config-logger-main.go
-
17config-version-main.go
-
6flags.go
-
21globals.go
-
26main.go
-
2pkg/contentdb/contentdb.go
-
4pkg/contentdb/db.go
-
62pkg/fs/config.go
-
6pkg/fs/fs-bucket.go
-
4pkg/fs/fs-multipart.go
-
18pkg/fs/fs.go
-
8pkg/fs/fs_test.go
-
49pkg/user/user.go
-
3routers.go
-
30server-config.go
-
36server-main.go
-
17server_fs_test.go
-
6update-main.go
-
32utils.go
@ -1,21 +0,0 @@ |
|||
/* |
|||
* Minio Cloud Storage, (C) 2015 Minio, Inc. |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
|
|||
package main |
|||
|
|||
var ( |
|||
globalJSONFlag = false // Json flag set via command line
|
|||
) |
@ -0,0 +1,49 @@ |
|||
package user |
|||
|
|||
import ( |
|||
"os" |
|||
"os/user" |
|||
"runtime" |
|||
"strconv" |
|||
) |
|||
|
|||
// Current is a portable implementation to determine the current user.
|
|||
// Golang's user.Current does not work reliably under docker or 32bit linux
|
|||
//
|
|||
// Two issues this code handles :-
|
|||
//
|
|||
// Docker Container - For static binaries NSS library will not be a part of the static binary hence user.Current() fails.
|
|||
// Linux Intel 32 bit - CGO is not enabled so it will not link with NSS library.
|
|||
//
|
|||
func Current() (*user.User, error) { |
|||
if os.Getenv("DOCKERIMAGE") == "1" { |
|||
wd, err := os.Getwd() |
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
return &user.User{Uid: "0", Gid: "0", Username: "root", Name: "root", HomeDir: wd}, nil |
|||
} |
|||
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, e := user.Current() |
|||
if e != nil { |
|||
return nil, e |
|||
} |
|||
return user, nil |
|||
} |
|||
|
|||
// HomeDir - return current home directory.
|
|||
func HomeDir() (string, error) { |
|||
user, err := Current() |
|||
if err != nil { |
|||
return "", err |
|||
} |
|||
return user.HomeDir, nil |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue