Skip to content

Commit

Permalink
use setcap instead of s bit if supported
Browse files Browse the repository at this point in the history
  • Loading branch information
joka90 committed Aug 28, 2022
1 parent d55ed19 commit bfcce40
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ The simplest way to build it:
make

modify permissions for executing as root when started from Ryzen controller
and user belongs to the ryzenadj group.
and user belongs to the ryzenadj group

setcap 'cap_sys_rawio=ep cap_dac_override=ep cap_sys_admin=ep' ./ryzenadj

or via the suid bit

sudo chow root:root ./ryzenadj
sudo chmod u+s ./ryzenadj
Expand Down
1 change: 1 addition & 0 deletions debian/apparmor/usr.bin.ryzenadj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ include <tunables/global>

capability sys_admin,
capability sys_rawio,
capability dac_override,

# Needed for some files in /proc see
# https://gitlab.com/apparmor/apparmor/-/wikis/TechnicalDoc_Proc_and_ptrace#apparmor-3-with-ptrace-rules
Expand Down
1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Depends: ${misc:Depends},
${shlibs:Depends},
libryzenadj0 (= ${binary:Version}),
Pre-Depends: adduser (>= 3.11),
libcap2-bin,
Description: Adjust power management settings for Ryzen Mobile Processors.
This is a commandline tool that allows you to adjust power management
settings for Ryzen Mobile Processors.
Expand Down
9 changes: 7 additions & 2 deletions debian/ryzenadj.postinst
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#!/bin/sh
# postinst script for #PACKAGE#

BINARY=/usr/bin/ryzenadj
case "$1" in
configure)
# Set setuid root on usr/bin/ryzenadj
chmod u+s /usr/bin/ryzenadj || ( echo 'Error: failed to setuid root on usr/bin/ryzenadj' >&2 )
if which setcap > /dev/null && setcap 'cap_sys_rawio=ep cap_dac_override=ep cap_sys_admin=ep' "$BINARY" ; then
echo "Set setcap on $BINARY successfull"
else
echo "Set setuid root on $BINARY"
chmod u+s "$BINARY" || ( echo "Error: failed to setuid root on $BINARY" >&2 )
fi
;;

*)
Expand Down

0 comments on commit bfcce40

Please sign in to comment.