summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2025-12-05 22:28:14 +0100
committerAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2025-12-05 22:28:36 +0100
commit4a30051a41e5140bf3624993cca5b1aeabbc6940 (patch)
tree6d361dff7d16b0fd8829ce99c4c05297869e7a6d
parenta2129744a520c1608067acb5774790c4a91548f4 (diff)
cgroups: properly handle cgroups for usersorigin/cgroup-rework
-rw-r--r--init.d/user.in9
-rw-r--r--sh/cgroups.sh4
-rw-r--r--sh/openrc-run.sh.in2
3 files changed, 14 insertions, 1 deletions
diff --git a/init.d/user.in b/init.d/user.in
index ea416e5c..1526599a 100644
--- a/init.d/user.in
+++ b/init.d/user.in
@@ -28,4 +28,13 @@ start_pre() {
eerror "symbolic links to it for the users you want to start"
return 1
fi
+
+ if [ -d "$cgroup_path" ]; then
+ local user_cgroup=${cgroup_path}/daemons
+
+ mkdir "$user_cgroup"
+ chown "$user:$user" "$user_cgroup"
+
+ cgroup_path="${cgroup_path}/system"
+ fi
}
diff --git a/sh/cgroups.sh b/sh/cgroups.sh
index ced0fdf9..854581d5 100644
--- a/sh/cgroups.sh
+++ b/sh/cgroups.sh
@@ -23,6 +23,10 @@ if [ -d "/sys/fs/cgroup/openrc.${RC_SVCNAME}" ]; then
cgroup_path="${cgroup_root}/openrc.${RC_SVCNAME}"
fi
+if yesno "$RC_USER_SERVICES" && [ -d "${cgroup_path}/daemons" ]; then
+ cgroup_path="${cgroup_path}/daemons"
+fi
+
cgroup_running()
{
[ -d "${cgroup_path}" ] ||
diff --git a/sh/openrc-run.sh.in b/sh/openrc-run.sh.in
index fe447b12..b6ccd8f3 100644
--- a/sh/openrc-run.sh.in
+++ b/sh/openrc-run.sh.in
@@ -57,7 +57,7 @@ sourcex "@LIBEXECDIR@/sh/functions.sh"
sourcex "@LIBEXECDIR@/sh/rc-functions.sh"
case $RC_SYS in
PREFIX|SYSTEMD-NSPAWN) ;;
- *) yesno "$RC_USER_SERVICES" || sourcex -e "@LIBEXECDIR@/sh/cgroups.sh";;
+ *) sourcex -e "@LIBEXECDIR@/sh/cgroups.sh";;
esac
# Support LiveCD foo