From: Mike Yuan Date: Tue, 26 Mar 2024 10:57:08 +0000 (+0800) Subject: core/execute: check if EXEC_PASS_FDS is set if got exec_params.fds X-Git-Tag: v256-rc1~392^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07ff03d6b2facc41b99521ef9382b8092f1df95e;p=thirdparty%2Fsystemd.git core/execute: check if EXEC_PASS_FDS is set if got exec_params.fds Prompted by #31789 (specifically https://github.com/systemd/systemd/pull/31789#discussion_r1525267612) --- diff --git a/src/core/execute.c b/src/core/execute.c index 864e3d49212..41b3b3f2b57 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 ba71f974744..be38ec73d8b 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -1681,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); }