Skip to content

Commit

Permalink
openrc-run.sh.in: Disable cgroups for user services.
Browse files Browse the repository at this point in the history
Since user services run as the user that is starting them, they won't be
able to make use of cgroups.

Signed-off-by: Anna (navi) Figueiredo Gomes <[email protected]>
  • Loading branch information
navi-desu committed Mar 14, 2023
1 parent 11e7764 commit ccd6b06
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions sh/openrc-run.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -271,23 +271,25 @@ for _cmd; do
fi
fi
# Apply cgroups settings if defined
if [ "$(command -v cgroup_add_service)" = "cgroup_add_service" ]
then
if grep -qs /sys/fs/cgroup /proc/1/mountinfo
if [ "${RC_USER_SERVICES}" != "YES" ]; then
if [ "$(command -v cgroup_add_service)" = "cgroup_add_service" ]
then
if [ -d /sys/fs/cgroup -a ! -w /sys/fs/cgroup ]; then
eerror "No permission to apply cgroup settings"
break
if grep -qs /sys/fs/cgroup /proc/1/mountinfo
then
if [ -d /sys/fs/cgroup -a ! -w /sys/fs/cgroup ]; then
eerror "No permission to apply cgroup settings"
break
fi
fi
cgroup_add_service
fi
cgroup_add_service
[ "$(command -v cgroup_set_limits)" = "cgroup_set_limits" ] &&
cgroup_set_limits
[ "$(command -v cgroup2_set_limits)" = "cgroup2_set_limits" ] &&
[ "$_cmd" = start ] &&
cgroup2_set_limits
break
fi
[ "$(command -v cgroup_set_limits)" = "cgroup_set_limits" ] &&
cgroup_set_limits
[ "$(command -v cgroup2_set_limits)" = "cgroup2_set_limits" ] &&
[ "$_cmd" = start ] &&
cgroup2_set_limits
break
fi
done

Expand Down

0 comments on commit ccd6b06

Please sign in to comment.