summaryrefslogtreecommitdiff
path: root/internal/user/name.go
diff options
context:
space:
mode:
authorPaul Bütow <pbuetow@mimecast.com>2020-01-26 11:26:53 +0000
committerPaul Bütow <pbuetow@mimecast.com>2020-02-07 13:31:15 +0000
commit0945da8dfefcbb723eecea0e5f4eafff63398253 (patch)
treef06dab4d2bf21d25d176b23d5baeca588d27f5d7 /internal/user/name.go
parent2a8e5de265a0e0a31a5834909d6879f5c9941467 (diff)
Introduce drun command, refactor code to use context package
Diffstat (limited to 'internal/user/name.go')
-rw-r--r--internal/user/name.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/internal/user/name.go b/internal/user/name.go
index 5171ec7..28ab0a4 100644
--- a/internal/user/name.go
+++ b/internal/user/name.go
@@ -2,10 +2,10 @@ package user
import (
"os/user"
- )
+)
-
-func Name() string {
+// 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)
@@ -18,7 +18,14 @@ func Name() string {
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
}
-