Commit 21dd7b46 authored by 4ast's avatar 4ast Committed by GitHub

Merge pull request #856 from brendangregg/master

check effective userid on run #850
parents 7f3c9928 a4a2de34
......@@ -282,12 +282,13 @@ class BPF(object):
print(log_buf.value.decode(), file=sys.stderr)
if fd < 0:
atexit.register(self.donothing)
if ct.get_errno() == errno.EPERM:
raise Exception("Need super-user privilges to run")
errstr = os.strerror(ct.get_errno())
if self.debug & DEBUG_BPF:
raise Exception("Failed to load BPF program %s: %s" %
(func_name, errstr))
else:
raise Exception("Failed to load BPF program %s: %s" % (func_name, errstr))
raise Exception("Failed to load BPF program %s: %s" %
(func_name, errstr))
fn = BPF.Function(self, func_name, fd)
self.funcs[func_name] = fn
......@@ -1027,6 +1028,9 @@ class BPF(object):
except KeyboardInterrupt:
exit()
def donothing(self):
"""the do nothing exit handler"""
def cleanup(self):
for k, v in list(self.open_kprobes.items()):
lib.perf_reader_free(v)
......
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