Commit e4a1245f authored by Frank Denis's avatar Frank Denis

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
parent b81a72cc
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment