Commit 22dc8d45 authored by williangaspar's avatar williangaspar

allow help to be printed

parent 99dd7733
......@@ -53,14 +53,19 @@ static void enforce_infinite_rlimit() {
"\"ulimit -l 8192\" to fix the problem" << std::endl;
}
int main(int argc, char *argv[])
bool is_root()
{
if (geteuid() != 0)
{
std::cerr << "ERROR: bpftrace currently only supports running as the root user." << std::endl;
exit(0);
return false;
}
else
return true;
}
int main(int argc, char *argv[])
{
int err;
Driver driver;
char *pid_str = NULL;
......@@ -107,6 +112,9 @@ int main(int argc, char *argv[])
// Listing probes
if (listing)
{
if (!is_root())
return 1;
if (optind == argc-1)
list_probes(argv[optind]);
else if (optind == argc)
......@@ -140,6 +148,9 @@ int main(int argc, char *argv[])
err = driver.parse_str(script);
}
if (!is_root())
return 1;
if (err)
return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment