Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bpftrace
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bpftrace
Commits
9e608df7
Commit
9e608df7
authored
Dec 28, 2018
by
Brendan Gregg
Committed by
GitHub
Dec 28, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #295 from iovisor/non_root
Better non-root error
parents
e89957ff
22dc8d45
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
src/main.cpp
src/main.cpp
+18
-0
No files found.
src/main.cpp
View file @
9e608df7
#include <iostream>
#include <signal.h>
#include <sys/resource.h>
#include <unistd.h>
#include "bpforc.h"
#include "bpftrace.h"
...
...
@@ -53,6 +54,17 @@ static void enforce_infinite_rlimit() {
"
\"
ulimit -l 8192
\"
to fix the problem"
<<
std
::
endl
;
}
bool
is_root
()
{
if
(
geteuid
()
!=
0
)
{
std
::
cerr
<<
"ERROR: bpftrace currently only supports running as the root user."
<<
std
::
endl
;
return
false
;
}
else
return
true
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
err
;
...
...
@@ -112,6 +124,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
)
...
...
@@ -145,6 +160,9 @@ int main(int argc, char *argv[])
err
=
driver
.
parse_str
(
script
);
}
if
(
!
is_root
())
return
1
;
if
(
err
)
return
err
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment