Skip to content

Instantly share code, notes, and snippets.

@nguyendangminh
Created June 24, 2015 02:51
Show Gist options
  • Save nguyendangminh/19b2fcf8aeb24d41a8b6 to your computer and use it in GitHub Desktop.
Save nguyendangminh/19b2fcf8aeb24d41a8b6 to your computer and use it in GitHub Desktop.
Check whether user is root
func get_root() (int) {
euid := os.Geteuid()
if euid != 0 {
fmt.Println("[-] You didn't run as root!")
fmt.Println("[-] Exiting...")
os.Exit(1)
}
return euid
}
def get_root():
euid = os.geteuid()
if euid != 0:
print '[-] You didn\'t run as root!'
print '[-] Exiting...'
sys.exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment