]> git.ipfire.org Git - thirdparty/systemd.git/commit
core: add new new bus call for migrating foreign processes to scope/service units
authorLennart Poettering <lennart@poettering.net>
Wed, 7 Feb 2018 21:52:52 +0000 (22:52 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 12 Feb 2018 10:34:00 +0000 (11:34 +0100)
commit6592b9759cae509b407a3b49603498468bf5d276
tree2623c8fdef3f27357d221c15a015429e93893419
parent931e47547d97e2d72e748d8147f9adba6113473b
core: add new new bus call for migrating foreign processes to scope/service units

This adds a new bus call to service and scope units called
AttachProcesses() that moves arbitrary processes into the cgroup of the
unit. The primary user for this new API is systemd itself: the systemd
--user instance uses this call of the systemd --system instance to
migrate processes if itself gets the request to migrate processes and
the kernel refuses this due to access restrictions.

The primary use-case of this is to make "systemd-run --scope --user …"
invoked from user session scopes work correctly on pure cgroupsv2
environments. There, the kernel refuses to migrate processes between two
unprivileged-owned cgroups unless the requestor as well as the ownership
of the closest parent cgroup all match. This however is not the case
between the session-XYZ.scope unit of a login session and the
user@ABC.service of the systemd --user instance.

The new logic always tries to move the processes on its own, but if
that doesn't work when being the user manager, then the system manager
is asked to do it instead.

The new operation is relatively restrictive: it will only allow to move
the processes like this if the caller is root, or the UID of the target
unit, caller and process all match. Note that this means that
unprivileged users cannot attach processes to scope units, as those do
not have "owning" users (i.e. they have now User= field).

Fixes: #3388
src/core/cgroup.c
src/core/cgroup.h
src/core/dbus-manager.c
src/core/dbus-scope.c
src/core/dbus-unit.c
src/core/dbus-unit.h
src/core/org.freedesktop.systemd1.conf
src/core/scope.c
src/core/unit.c
src/core/unit.h