diff options
| author | Paul Bütow <pbuetow@mimecast.com> | 2020-01-20 18:41:05 +0000 |
|---|---|---|
| committer | Paul Bütow <pbuetow@mimecast.com> | 2020-01-21 14:35:23 +0000 |
| commit | c128865c4c7411c29a59fca9a3a2f95537686d7b (patch) | |
| tree | 193bccc70d942c8b70cc93fae2670263701e43aa /internal/user/name.go | |
| parent | 3755a9911ecb05886577095f2b8cc8b9e4066a3a (diff) | |
Move commands to cmd/ and move internal dependencies to internal/
Diffstat (limited to 'internal/user/name.go')
| -rw-r--r-- | internal/user/name.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/user/name.go b/internal/user/name.go new file mode 100644 index 0000000..5171ec7 --- /dev/null +++ b/internal/user/name.go @@ -0,0 +1,24 @@ +package user + +import ( + "os/user" + ) + + +func Name() string { + 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") + } + + return user.Username +} + |
