Add setcap helper
This will setcap the perf stats helper appropriately when installed by root. It wont fail if you try an unprivileged install, but it means the perf stats helper also wont work. Also check that we have the CAP_PERFMON capability in the kernel as this isnt supported on ubuntu 20. On this platform packagers should setuid as root.pull/877/head
parent
96b605ce88
commit
5db1bc427f
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Simple post-install script to setcap the metrics helper
|
||||||
|
|
||||||
|
setcap="${1?SETCAP_UNSET}"
|
||||||
|
bindir="${2?BINDIR_UNSET}"
|
||||||
|
exe="${3?EXE_UNSET}"
|
||||||
|
exe_fullpath="$MESON_INSTALL_DESTDIR_PREFIX/$bindir/$exe"
|
||||||
|
|
||||||
|
euid=$(id -u)
|
||||||
|
if [ $euid != "0" ]; then
|
||||||
|
echo "Warning: installed by unprivileged user, could not setcap $exe_fullpath" >&2
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
if ! capsh --supports=CAP_PERFMON; then
|
||||||
|
echo "Warning: build environment does not support CAP_PERFMON, you must setuid root on this platform" >&2
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
"$setcap" cap_perfmon=+ep "$exe_fullpath"
|
Loading…
Reference in New Issue