]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/core/unit.c
core: when creating the socket fds for a socket unit, join socket's cgroup first
authorLennart Poettering <lennart@poettering.net>
Thu, 7 Sep 2017 09:17:43 +0000 (11:17 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 22 Sep 2017 13:24:55 +0000 (15:24 +0200)
commita79279c7fd9f43680da7d5cac382981cf7714f52
tree23dbc1c95b042a53c65a79c3987f33e57e3d7cec
parent5ed272cf928b5f2d7420b5568390a8190c8d52fe
core: when creating the socket fds for a socket unit, join socket's cgroup first

Let's make sure that a socket unit's IPAddressAllow=/IPAddressDeny=
settings are in effect on all socket fds associated with it. In order to
make this happen we need to make sure the cgroup the fds are associated
with are the socket unit's cgroup. The only way to do that is invoking
socket()+accept() in them. Since we really don't want to migrate PID 1
around we do this by forking off a helper process, which invokes
socket()/accept() and sends the newly created fd to PID 1. Ugly, but
works, and there's apparently no better way right now.

This generalizes forking off per-unit helper processes in a new function
unit_fork_helper_process(), which is then also used by the NSS chown()
code of socket units.
src/core/socket.c
src/core/unit.c
src/core/unit.h