Upload files to ''
check if root. first go code!
This commit is contained in:
parent
9019354125
commit
519f4e26d9
33
rootchk.go
Normal file
33
rootchk.go
Normal file
@ -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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user