Skip to content

Commit 09a6918

Browse files
committed
Use os.Geteuid()
Fixes #2224
1 parent c748630 commit 09a6918

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

dnscrypt-proxy/privilege_linux.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import (
1515
)
1616

1717
func (proxy *Proxy) dropPrivilege(userStr string, fds []*os.File) {
18-
currentUser, err := user.Current()
19-
if err != nil && currentUser.Uid != "0" {
18+
if os.Geteuid() != 0 {
2019
dlog.Fatal("Root privileges are required in order to switch to a different user. Maybe try again with 'sudo'")
2120
}
2221
userInfo, err := user.Lookup(userStr)

dnscrypt-proxy/privilege_others.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import (
1717
)
1818

1919
func (proxy *Proxy) dropPrivilege(userStr string, fds []*os.File) {
20-
currentUser, err := user.Current()
21-
if err != nil && currentUser.Uid != "0" {
20+
if os.Geteuid() != 0 {
2221
dlog.Fatal("Root privileges are required in order to switch to a different user. Maybe try again with 'sudo'")
2322
}
2423
userInfo, err := user.Lookup(userStr)

0 commit comments

Comments
 (0)