On socket creation respect the SELinuxContext= setting of the associated
service, such that the initial created socket has the same label as the
future process accepting the connection (since w.r.t SELinux sockets
normally have the same label as the owning process).
Triggered by #24702
Unit *service;
ExecCommand *c;
+ const char *exec_context;
_cleanup_free_ char *path = NULL;
r = socket_load_service_unit(s, -1, &service);
if (r < 0)
return r;
+ exec_context = SERVICE(service)->exec_context.selinux_context;
+ if (exec_context) {
+ char *con;
+
+ con = strdup(exec_context);
+ if (!con)
+ return -ENOMEM;
+
+ *ret = TAKE_PTR(con);
+ return 0;
+ }
+
c = SERVICE(service)->exec_command[SERVICE_EXEC_START];
if (!c)
goto no_label;