]> git.ipfire.org Git - thirdparty/systemd.git/commit
core: create socket service instances with the correct name from the start
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 29 May 2020 12:24:12 +0000 (14:24 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 10 Jun 2020 07:45:55 +0000 (09:45 +0200)
commit934ef6a5220a0486ef4c212c01a91064024cb998
tree9e9c219f396e85a5f29df8207163b407f9890888
parentada4b34ec7159e01af11068f99b28cce8a891ad1
core: create socket service instances with the correct name from the start

Upon an incoming connection for an accepting socket, we'd create a unit like
foo@0.service, then figure out that the instance name should be e.g. "0-41-0",
and then add the name foo@0-41-0.service to the unit. This obviously violates
the rule that any service needs to have a constance instance part.

So let's reverse the order: we first determine the instance name and then
create the unit with the correct name from the start.

There are two cases where we don't know the instance name:
- analyze-verify: we just do a quick check that the instance unit can be
  created. So let's use a bogus instance string.
- selinux: the code wants to load the service unit to extract the ExecStart path
  and query it for the selinux label. Do the same as above.

Note that in both cases it is possible that the real unit that is loaded could
be different than the one with the bogus instance value, for example if there
is a dropin for a specific instance name. We can't do much about this, since we
can't figure out the instance name in advance. The old code had the same
shortcoming.
src/analyze/analyze-verify.c
src/core/socket.c
src/core/socket.h