Use os.Geteuid()

Fixes #2224
This commit is contained in:
Frank Denis 2022-10-18 14:56:39 +02:00
parent c748630691
commit 09a6918226
2 changed files with 2 additions and 4 deletions

View File

@ -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)

View File

@ -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)