Add test for "are we running as root".

Most operations require root access.  Rather than ensure we generate
the right error message when something fails because we aren't root,
check early.
Note that "--examine" does not necessarily require root, so test
for that first.

Resolves-Debian-bug: 396570
Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2010-02-01 10:22:38 +11:00
parent cf1be220e2
commit ac5678dd9b
1 changed files with 6 additions and 0 deletions

View File

@ -1046,6 +1046,12 @@ int main(int argc, char *argv[])
}
}
if ((mode != MISC || devmode != 'E') &&
geteuid() != 0) {
fprintf(stderr, Name ": must be super-user to perform this action\n");
exit(1);
}
ident.autof = autof;
rv = 0;