From 519f4e26d96946e99557e125cce80d9c6aeec044 Mon Sep 17 00:00:00 2001 From: Morrigan Date: Sat, 23 Mar 2019 21:27:14 -0700 Subject: [PATCH] Upload files to '' check if root. first go code! --- rootchk.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 rootchk.go diff --git a/rootchk.go b/rootchk.go new file mode 100644 index 0000000..6f04358 --- /dev/null +++ b/rootchk.go @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + //"os" + "os/user" + "strconv" +) + +var ( +isroot int = 0 + +) +func chkroot(){ + user, err := user.Current() + if err != nil { + panic(err) + } + + id1, err := strconv.Atoi(user.Uid) //converts uid to a int + if id1 == 0 { //cheks if uid = 0 + isroot = 1 + } + + + + +} + +func main() { +chkroot() +fmt.Println(isroot) +}