From 934ef6a5220a0486ef4c212c01a91064024cb998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 29 May 2020 14:24:12 +0200 Subject: 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/core/socket.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/socket.h') diff --git a/src/core/socket.h b/src/core/socket.h index 9e0be15ba8..848eeb9c67 100644 --- a/src/core/socket.h +++ b/src/core/socket.h @@ -165,7 +165,7 @@ void socket_connection_unref(Socket *s); void socket_free_ports(Socket *s); -int socket_instantiate_service(Socket *s); +int socket_load_service_unit(Socket *s, int cfd, Unit **ret); char *socket_fdname(Socket *s); -- cgit v1.2.1