Merge pull request #30450 from poettering/cgroups-delegate-attr-update

cgroup: bring list of delegated cgroup attributes up-to-date with cur…
This commit is contained in:
Luca Boccassi 2023-12-13 13:50:41 +00:00 committed by GitHub
commit b896058883
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View file

@ -35,6 +35,8 @@ static int chown_cgroup_path(const char *path, uid_t uid_shift) {
"cgroup.stat",
"cgroup.subtree_control",
"cgroup.threads",
"memory.oom.group",
"memory.reclaim",
"notify_on_release",
"tasks")
if (fchownat(fd, fn, uid_shift, uid_shift, 0) < 0)

View file

@ -421,6 +421,8 @@ int cg_set_access(
{ "cgroup.procs", true },
{ "cgroup.subtree_control", true },
{ "cgroup.threads", false },
{ "memory.oom.group", false },
{ "memory.reclaim", false },
{},
};

View file

@ -26,6 +26,19 @@ systemd-run --wait \
-w /sys/fs/cgroup/system.slice/test-0.service/cgroup.procs -a \
-w /sys/fs/cgroup/system.slice/test-0.service/cgroup.subtree_control
# Test if this also works for some of the more recent attrs the kernel might or might not support
for attr in cgroup.threads memory.oom.group memory.reclaim ; do
if grep -q "$attr" /sys/kernel/cgroup/delegate ; then
systemd-run --wait \
--unit=test-0.service \
--property="DynamicUser=1" \
--property="Delegate=" \
test -w /sys/fs/cgroup/system.slice/test-0.service/ -a \
-w /sys/fs/cgroup/system.slice/test-0.service/"$attr"
fi
done
systemd-run --wait \
--unit=test-1.service \
--property="DynamicUser=1" \