user.Current() fails when CGO is disabled and USER/HOME are not defined
So, ignore it if it fails. This used to happen on Linux; not sure about other systems. Fixes #607
This commit is contained in:
parent
b81a72cc3e
commit
e4a1245fb2
|
@ -16,11 +16,8 @@ var cmd *exec.Cmd
|
|||
|
||||
func (proxy *Proxy) dropPrivilege(userStr string, fds []*os.File) {
|
||||
currentUser, err := user.Current()
|
||||
if err != nil {
|
||||
dlog.Fatal(err)
|
||||
}
|
||||
if currentUser.Uid != "0" {
|
||||
dlog.Fatal("I need root permissions. Try again with 'sudo'")
|
||||
if err != nil && currentUser.Uid != "0" {
|
||||
dlog.Fatal("Root privileges are required in order to switch to a different user. Maybe try again with 'sudo'")
|
||||
}
|
||||
userInfo, err := user.Lookup(userStr)
|
||||
args := os.Args
|
||||
|
|
|
@ -18,11 +18,8 @@ var cmd *exec.Cmd
|
|||
|
||||
func (proxy *Proxy) dropPrivilege(userStr string, fds []*os.File) {
|
||||
currentUser, err := user.Current()
|
||||
if err != nil {
|
||||
dlog.Fatal(err)
|
||||
}
|
||||
if currentUser.Uid != "0" {
|
||||
dlog.Fatal("I need root permissions. Try again with 'sudo'")
|
||||
if err != nil && currentUser.Uid != "0" {
|
||||
dlog.Fatal("Root privileges are required in order to switch to a different user. Maybe try again with 'sudo'")
|
||||
}
|
||||
user, err := user.Lookup(userStr)
|
||||
args := os.Args
|
||||
|
|
Loading…
Reference in New Issue