]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: allow slice to be overriden if cgroups aren't realized (#3246)
authorTejun Heo <htejun@fb.com>
Sat, 14 May 2016 19:56:53 +0000 (15:56 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 14 May 2016 19:56:53 +0000 (15:56 -0400)
unit_set_slice() fails with -EBUSY if the unit already has a slice associated
with it.  This makes it impossible to override slice through dropin config or
over dbus.  There's no reason to disallow slice changes as long as cgroups
aren't realized.  Fix it.

Fixes #3240.

Signed-off-by: Tejun Heo <htejun@fb.com>
Reported-by: Davide Cavalca <dcavalca@fb.com>
src/core/unit.c

index d8ab5781b06fb9e95ba348efc4e912e8053a89fa..dc8325515c74575a0b683ac1e872d7750eb0fce0 100644 (file)
@@ -2400,9 +2400,11 @@ int unit_set_slice(Unit *u, Unit *slice) {
         if (UNIT_DEREF(u->slice) == slice)
                 return 0;
 
-        if (UNIT_ISSET(u->slice))
+        /* Disallow slice changes if @u is already bound to cgroups */
+        if (UNIT_ISSET(u->slice) && u->cgroup_realized)
                 return -EBUSY;
 
+        unit_ref_unset(&u->slice);
         unit_ref_set(&u->slice, slice);
         return 1;
 }