pid1: add D-Bus API for removing delegated subcgroups
When running unprivileged containers, we run into a scenario where an unpriv owned cgroup has a subcgroup delegated to another user (i.e. the container's own UIDs). When the owner of that cgroup dies without cleaning it up then the unpriv service manager might encounter a cgroup it cannot delete anymore. Let's address that: let's expose a method call on the service manager (primarly in PID1) that can be used to delete a subcgroup of a unit one owns. This would then allow the unpriv service manager to ask the priv service manager to get rid of such a cgroup. This commit only adds the method call, the next commit then adds the code that makes use of this.
This commit is contained in:
@@ -960,6 +960,12 @@ static int method_attach_processes_to_unit(sd_bus_message *message, void *userda
|
||||
return method_generic_unit_operation(message, userdata, error, bus_unit_method_attach_processes, GENERIC_UNIT_VALIDATE_LOADED);
|
||||
}
|
||||
|
||||
static int method_remove_subgroup_from_unit(sd_bus_message *message, void *userdata, sd_bus_error *error) {
|
||||
/* Don't allow removal of subgroups from units that aren't loaded. But allow loading the unit, since
|
||||
* this is clean-up work, that is OK to do when the unit is stopped already. */
|
||||
return method_generic_unit_operation(message, userdata, error, bus_unit_method_remove_subgroup, GENERIC_UNIT_LOAD|GENERIC_UNIT_VALIDATE_LOADED);
|
||||
}
|
||||
|
||||
static int transient_unit_from_message(
|
||||
Manager *m,
|
||||
sd_bus_message *message,
|
||||
@@ -3246,6 +3252,11 @@ const sd_bus_vtable bus_manager_vtable[] = {
|
||||
SD_BUS_NO_RESULT,
|
||||
method_attach_processes_to_unit,
|
||||
SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
SD_BUS_METHOD_WITH_ARGS("RemoveSubgroupFromUnit",
|
||||
SD_BUS_ARGS("s", unit_name, "s", subcgroup, "t", flags),
|
||||
SD_BUS_NO_RESULT,
|
||||
method_remove_subgroup_from_unit,
|
||||
SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
SD_BUS_METHOD_WITH_ARGS("AbandonScope",
|
||||
SD_BUS_ARGS("s", name),
|
||||
SD_BUS_NO_RESULT,
|
||||
|
||||
Reference in New Issue
Block a user