]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/cgroup: assigning empty string to Delegate= resets list of controllers (#7336)
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 17 Nov 2017 09:04:25 +0000 (18:04 +0900)
committerLennart Poettering <lennart@poettering.net>
Fri, 17 Nov 2017 09:04:25 +0000 (10:04 +0100)
Before this, assigning empty string to Delegate= makes no change to the
controller list. This is inconsistent to the other options that take list
of strings. After this, when empty string is assigned to Delegate=, the
list of controllers is reset. Such behavior is consistent to other options
and useful for drop-in configs.

Closes #7334.

man/systemd.resource-control.xml
src/core/dbus-cgroup.c
src/core/load-fragment.c

index 761a6056dec73cd3c4ae432d39b7cb47ca31e245..9bf2d7e774cd34099b6faff57ac4466b6de60c0a 100644 (file)
           enabled for the unit, making them available to the unit's processes for management. If false, delegation is
           turned off entirely (and no additional controllers are enabled). If set to a list of controllers, delegation
           is turned on, and the specified controllers are enabled for the unit. Note that assigning the empty string
-          will enable delegation, but not enable any additional controllers. Defaults to false.</para>
+          will enable delegation, but reset the list of controllers, all assignments prior to this will have no effect.
+          Defaults to false.</para>
 
           <para>Note that controller delegation to less privileged code is only safe on the unified control group
           hierarchy. Accordingly, access to the specified controllers will not be granted to unprivileged services on
index dd8aa183636d7ce9582d72d0f76805d72db2cde7..e8e8b89bb2aa59263d97e563859d570ce53209ba 100644 (file)
@@ -395,9 +395,12 @@ static int bus_cgroup_set_transient_property(
                                 return r;
 
                         c->delegate = true;
-                        c->delegate_controllers |= mask;
+                        if (mask == 0)
+                                c->delegate_controllers = 0;
+                        else
+                                c->delegate_controllers |= mask;
 
-                        unit_write_drop_in_private_format(u, mode, name, "Delegate=%s", t);
+                        unit_write_drop_in_private_format(u, mode, name, "Delegate=%s", strempty(t));
                 }
 
                 return 1;
index c1cf8379e8286c7d6e350822759da00aa7423e32..52a10dd24bcddcc67eeaa726c57f50fa5f987ce5 100644 (file)
@@ -3297,6 +3297,12 @@ int config_parse_delegate(
          * off for all. Or it takes a list of controller names, in which case we add the specified controllers to the
          * mask to delegate. */
 
+        if (isempty(rvalue)) {
+                c->delegate = true;
+                c->delegate_controllers = 0;
+                return 0;
+        }
+
         r = parse_boolean(rvalue);
         if (r < 0) {
                 const char *p = rvalue;