Verify golang runtime for 0.5.1 and above, also verify if runner is a root

This commit is contained in:
Harshavardhana
2015-09-09 15:29:28 -07:00
parent 17f5df689e
commit d3f9a9da0d
2 changed files with 110 additions and 1 deletions

11
main.go
View File

@@ -31,10 +31,19 @@ import (
func init() {
// Check for the environment early on and gracefuly report.
_, err := user.Current()
u, err := user.Current()
if err != nil {
Fatalf("Unable to obtain user's home directory. \nError: %s\n", err)
}
var uid int
uid, err = strconv.Atoi(u.Uid)
if err != nil {
Fatalf("Unable to convert user id to an integer. \nError: %s\n", err)
}
if uid == 0 {
Fatalln("Please run as a normal user, running as root is disallowed")
}
verifyMinioRuntime()
}
// Tries to get os/arch/platform specific information