summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-03-26 18:37:23 +0100
committerGitHub <noreply@github.com>2024-03-26 18:37:23 +0100
commit18640f821144f449012231ce0e3e373c8f7fe9e5 (patch)
tree1248547127d02d40db59e8d4887e9eac2fac7c0f /src
parentMerge pull request #31960 from YHNdnzj/capsule-followup (diff)
parentcore/execute: check if EXEC_PASS_FDS is set if got exec_params.fds (diff)
downloadsystemd-18640f821144f449012231ce0e3e373c8f7fe9e5.tar.xz
systemd-18640f821144f449012231ce0e3e373c8f7fe9e5.zip
Merge pull request #31959 from YHNdnzj/execute-pass-fds
core/execute: check if EXEC_PASS_FDS is set if got exec_params.fds
Diffstat (limited to 'src')
-rw-r--r--src/core/execute.c3
-rw-r--r--src/core/service.c7
2 files changed, 6 insertions, 4 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index 864e3d4921..41b3b3f2b5 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -374,7 +374,8 @@ int exec_spawn(Unit *unit,
assert(command);
assert(context);
assert(params);
- assert(params->fds || (params->n_socket_fds + params->n_storage_fds <= 0));
+ assert(!params->fds || FLAGS_SET(params->flags, EXEC_PASS_FDS));
+ assert(params->fds || (params->n_socket_fds + params->n_storage_fds == 0));
assert(!params->files_env); /* We fill this field, ensure it comes NULL-initialized to us */
assert(ret);
diff --git a/src/core/service.c b/src/core/service.c
index 953cb2934a..be38ec73d8 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -1409,10 +1409,9 @@ static int service_collect_fds(
Socket *sock;
int cn_fds;
- if (u->type != UNIT_SOCKET)
- continue;
-
sock = SOCKET(u);
+ if (!sock)
+ continue;
cn_fds = socket_collect_fds(sock, &cfds);
if (cn_fds < 0)
@@ -1682,6 +1681,8 @@ static int service_spawn_internal(
exec_params.open_files = s->open_files;
+ exec_params.flags |= EXEC_PASS_FDS;
+
log_unit_debug(UNIT(s), "Passing %zu fds to service", exec_params.n_socket_fds + exec_params.n_storage_fds);
}