Skip to content

Commit 42de4ef

Browse files
committed
use setcap instead of s bit if supported
1 parent af7dce9 commit 42de4ef

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,11 @@ The simplest way to build it:
129129
make
130130

131131
modify permissions for executing as root when started from Ryzen controller
132-
and user belongs to the ryzenadj group.
132+
and user belongs to the ryzenadj group
133+
134+
setcap 'cap_sys_rawio=ep cap_dac_override=ep cap_sys_admin=ep' ./ryzenadj
135+
136+
or via the suid bit
133137

134138
sudo chow root:root ./ryzenadj
135139
sudo chmod u+s ./ryzenadj

debian/apparmor/usr.bin.ryzenadj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ include <tunables/global>
1010

1111
capability sys_admin,
1212
capability sys_rawio,
13+
capability dac_override,
1314

1415
# Needed for some files in /proc see
1516
# https://gitlab.com/apparmor/apparmor/-/wikis/TechnicalDoc_Proc_and_ptrace#apparmor-3-with-ptrace-rules

debian/control

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Depends: ${misc:Depends},
2020
${shlibs:Depends},
2121
libryzenadj0 (= ${binary:Version}),
2222
Pre-Depends: adduser (>= 3.11),
23+
libcap2-bin,
2324
Description: Adjust power management settings for Ryzen Mobile Processors.
2425
This is a commandline tool that allows you to adjust power management
2526
settings for Ryzen Mobile Processors.

debian/ryzenadj.postinst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
#!/bin/sh
22
# postinst script for #PACKAGE#
33

4+
BINARY=/usr/bin/ryzenadj
45
case "$1" in
56
configure)
6-
# Set setuid root on usr/bin/ryzenadj
7-
chmod u+s /usr/bin/ryzenadj || ( echo 'Error: failed to setuid root on usr/bin/ryzenadj' >&2 )
7+
if which setcap > /dev/null && setcap 'cap_sys_rawio=ep cap_dac_override=ep cap_sys_admin=ep' "$BINARY" ; then
8+
echo "Set setcap on $BINARY successfull"
9+
else
10+
echo "Set setuid root on $BINARY"
11+
chmod u+s "$BINARY" || ( echo "Error: failed to setuid root on $BINARY" >&2 )
12+
fi
813
;;
914

1015
*)

0 commit comments

Comments
 (0)