From: Mike Yuan Date: Tue, 4 Nov 2025 10:04:50 +0000 (+0100) Subject: core/socket: fix alignment, extract common conditions X-Git-Tag: v259-rc1~136^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dfb4b39d4d764a6242554d7b4d7f54f0197eca76;p=thirdparty%2Fsystemd.git core/socket: fix alignment, extract common conditions --- diff --git a/src/core/socket.c b/src/core/socket.c index cc339d631d4..c53f84906fe 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -1580,31 +1580,27 @@ static int socket_address_listen_in_cgroup( if (r < 0) return log_unit_error_errno(UNIT(s), r, "Failed to acquire runtime: %m"); - if (s->exec_context.user_namespace_path && - s->exec_runtime && - s->exec_runtime->shared && - s->exec_runtime->shared->userns_storage_socket[0] >= 0) { - r = open_shareable_ns_path(s->exec_runtime->shared->userns_storage_socket, s->exec_context.user_namespace_path, CLONE_NEWUSER); - if (r < 0) - return log_unit_error_errno(UNIT(s), r, "Failed to open user namespace path %s: %m", s->exec_context.user_namespace_path); - } + if (s->exec_runtime && s->exec_runtime->shared) { + if (s->exec_context.user_namespace_path && + s->exec_runtime->shared->userns_storage_socket[0] >= 0) { + r = open_shareable_ns_path(s->exec_runtime->shared->userns_storage_socket, s->exec_context.user_namespace_path, CLONE_NEWUSER); + if (r < 0) + return log_unit_error_errno(UNIT(s), r, "Failed to open user namespace path %s: %m", s->exec_context.user_namespace_path); + } - if (s->exec_context.network_namespace_path && - s->exec_runtime && - s->exec_runtime->shared && - s->exec_runtime->shared->netns_storage_socket[0] >= 0) { - r = open_shareable_ns_path(s->exec_runtime->shared->netns_storage_socket, s->exec_context.network_namespace_path, CLONE_NEWNET); - if (r < 0) - return log_unit_error_errno(UNIT(s), r, "Failed to open network namespace path %s: %m", s->exec_context.network_namespace_path); - } + if (s->exec_context.network_namespace_path && + s->exec_runtime->shared->netns_storage_socket[0] >= 0) { + r = open_shareable_ns_path(s->exec_runtime->shared->netns_storage_socket, s->exec_context.network_namespace_path, CLONE_NEWNET); + if (r < 0) + return log_unit_error_errno(UNIT(s), r, "Failed to open network namespace path %s: %m", s->exec_context.network_namespace_path); + } - if (s->exec_context.ipc_namespace_path && - s->exec_runtime && - s->exec_runtime->shared && - s->exec_runtime->shared->ipcns_storage_socket[0] >= 0) { - r = open_shareable_ns_path(s->exec_runtime->shared->ipcns_storage_socket, s->exec_context.ipc_namespace_path, CLONE_NEWIPC); - if (r < 0) - return log_unit_error_errno(UNIT(s), r, "Failed to open IPC namespace path %s: %m", s->exec_context.ipc_namespace_path); + if (s->exec_context.ipc_namespace_path && + s->exec_runtime->shared->ipcns_storage_socket[0] >= 0) { + r = open_shareable_ns_path(s->exec_runtime->shared->ipcns_storage_socket, s->exec_context.ipc_namespace_path, CLONE_NEWIPC); + if (r < 0) + return log_unit_error_errno(UNIT(s), r, "Failed to open IPC namespace path %s: %m", s->exec_context.ipc_namespace_path); + } } if (socketpair(AF_UNIX, SOCK_SEQPACKET|SOCK_CLOEXEC, 0, pair) < 0)