From 99e66921c86bce77d0d3587c201c7d1b611a7d99 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 14 May 2016 15:56:53 -0400 Subject: core: allow slice to be overriden if cgroups aren't realized (#3246) 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 Reported-by: Davide Cavalca --- src/core/unit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/core/unit.c') diff --git a/src/core/unit.c b/src/core/unit.c index d8ab5781b0..dc8325515c 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -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; } -- cgit v1.2.3-54-g00ecf