diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-02-06 11:57:35 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-02-12 11:34:00 +0100 |
commit | 1d9cc8768f173b25757c01aa0d4c7be7cd7116bc (patch) | |
tree | 1a7d700eea0e9835e782f48823468902e351d0d2 /src/core/dbus-cgroup.c | |
parent | Merge pull request #8143 from yuwata/drop-unused-func (diff) | |
download | systemd-1d9cc8768f173b25757c01aa0d4c7be7cd7116bc.tar.xz systemd-1d9cc8768f173b25757c01aa0d4c7be7cd7116bc.zip |
cgroup: add a new "can_delegate" flag to the unit vtable, and set it for scope and service units only
Currently we allowed delegation for alluntis with cgroup backing
except for slices. Let's make this a bit more strict for now, and only
allow this in service and scope units.
Let's also add a generic accessor unit_cgroup_delegate() for checking
whether a unit has delegation turned on that checks the new bool first.
Also, when doing transient units, let's explcitly refuse turning on
delegation for unit types that don#t support it. This is mostly
cosmetical as we wouldn't act on the delegation request anyway, but
certainly helpful for debugging.
Diffstat (limited to 'src/core/dbus-cgroup.c')
-rw-r--r-- | src/core/dbus-cgroup.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c index f8d90d4b3a..30456fa9f5 100644 --- a/src/core/dbus-cgroup.c +++ b/src/core/dbus-cgroup.c @@ -351,6 +351,9 @@ static int bus_cgroup_set_transient_property( if (streq(name, "Delegate")) { int b; + if (!UNIT_VTABLE(u)->can_delegate) + return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Delegation not available for unit type"); + r = sd_bus_message_read(message, "b", &b); if (r < 0) return r; @@ -367,6 +370,9 @@ static int bus_cgroup_set_transient_property( } else if (streq(name, "DelegateControllers")) { CGroupMask mask = 0; + if (!UNIT_VTABLE(u)->can_delegate) + return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Delegation not available for unit type"); + r = sd_bus_message_enter_container(message, 'a', "s"); if (r < 0) return r; |