From 0f51ca0a77f2b592d3bdff113e3b0f4e429c9e95 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 30 Sep 2015 10:49:26 -0700 Subject: [PATCH] Strconv for UID on windows doesn't work since UID is not an number on windows There is no portable way to know, ignore root check for windows for now. --- main.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 233d6d25..0dfcecd1 100644 --- a/main.go +++ b/main.go @@ -32,15 +32,13 @@ import ( // Check for the user id erarly on and gracefully report. func checkUser() { - u, e := user.Current() + _, e := user.Current() fatalIf(probe.NewError(e), "Unable to determine current user.") - var uid int - uid, e = strconv.Atoi(u.Uid) - fatalIf(probe.NewError(e), "Unable to convert user id to an integer.") - - if uid == 0 { - fatalIf(errDummy().Trace(), "Please run as a normal user, running as root is disallowed") + if runtime.GOOS != "windows" { + if os.Geteuid() == 0 { + fatalIf(errDummy().Trace(), "Please run as a normal user, running as root is disallowed") + } } }