blob: cd11907be51fe48ccb5a771b8b3f47f075dadbb4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package user
import (
"os/user"
)
// NoRootCheck verifies that the DTail run user is not with UID or GID 0.
func NoRootCheck() {
user, err := user.Current()
if err != nil {
panic(err)
}
if user.Uid == "0" {
panic("Not allowed to run as UID 0")
}
if user.Gid == "0" {
panic("Not allowed to run as GID 0")
}
}
// Name of the current run user.
func Name() string {
user, err := user.Current()
if err != nil {
panic(err)
}
return user.Username
}
|