Skip to content

Commit 4a30051

Browse files
committed
cgroups: properly handle cgroups for users
1 parent a212974 commit 4a30051

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

init.d/user.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,13 @@ start_pre() {
2828
eerror "symbolic links to it for the users you want to start"
2929
return 1
3030
fi
31+
32+
if [ -d "$cgroup_path" ]; then
33+
local user_cgroup=${cgroup_path}/daemons
34+
35+
mkdir "$user_cgroup"
36+
chown "$user:$user" "$user_cgroup"
37+
38+
cgroup_path="${cgroup_path}/system"
39+
fi
3140
}

sh/cgroups.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ if [ -d "/sys/fs/cgroup/openrc.${RC_SVCNAME}" ]; then
2323
cgroup_path="${cgroup_root}/openrc.${RC_SVCNAME}"
2424
fi
2525

26+
if yesno "$RC_USER_SERVICES" && [ -d "${cgroup_path}/daemons" ]; then
27+
cgroup_path="${cgroup_path}/daemons"
28+
fi
29+
2630
cgroup_running()
2731
{
2832
[ -d "${cgroup_path}" ] ||

sh/openrc-run.sh.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ sourcex "@LIBEXECDIR@/sh/functions.sh"
5757
sourcex "@LIBEXECDIR@/sh/rc-functions.sh"
5858
case $RC_SYS in
5959
PREFIX|SYSTEMD-NSPAWN) ;;
60-
*) yesno "$RC_USER_SERVICES" || sourcex -e "@LIBEXECDIR@/sh/cgroups.sh";;
60+
*) sourcex -e "@LIBEXECDIR@/sh/cgroups.sh";;
6161
esac
6262

6363
# Support LiveCD foo

0 commit comments

Comments
 (0)