diff --git a/dnscrypt-proxy/privilege_linux.go b/dnscrypt-proxy/privilege_linux.go index dcadd3b7..1908a4b7 100644 --- a/dnscrypt-proxy/privilege_linux.go +++ b/dnscrypt-proxy/privilege_linux.go @@ -15,8 +15,7 @@ import ( ) func (proxy *Proxy) dropPrivilege(userStr string, fds []*os.File) { - currentUser, err := user.Current() - if err != nil && currentUser.Uid != "0" { + if os.Geteuid() != 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) diff --git a/dnscrypt-proxy/privilege_others.go b/dnscrypt-proxy/privilege_others.go index 81b1741b..195aa1ce 100644 --- a/dnscrypt-proxy/privilege_others.go +++ b/dnscrypt-proxy/privilege_others.go @@ -17,8 +17,7 @@ import ( ) func (proxy *Proxy) dropPrivilege(userStr string, fds []*os.File) { - currentUser, err := user.Current() - if err != nil && currentUser.Uid != "0" { + if os.Geteuid() != 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)