Name: Anonymous 2008-01-22 18:24
How would I make my program check if it was root?
$ env USER=root ./\>\>10\'s\ shitty\ program
you are root
$#include <pwd.h>
#include <stdio.h>
#include <unistd.h>
int main(){
puts(
strcmp(getpwuid(geteuid())->pw_name, "root") ?
"not running as root"
: "running as root"
);
return 0;
}