]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/execute: check if EXEC_PASS_FDS is set if got exec_params.fds 31959/head
authorMike Yuan <me@yhndnzj.com>
Tue, 26 Mar 2024 10:57:08 +0000 (18:57 +0800)
committerMike Yuan <me@yhndnzj.com>
Tue, 26 Mar 2024 12:08:52 +0000 (20:08 +0800)
Prompted by #31789 (specifically
https://github.com/systemd/systemd/pull/31789#discussion_r1525267612)

src/core/execute.c
src/core/service.c

index 864e3d492121937b25bd6c2294a7bc0dd7ab18fa..41b3b3f2b57e7347439c169a848c3d63cc547f38 100644 (file)
@@ -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);
 
index ba71f974744dde7d054540d3bdcc6e38c133c01e..be38ec73d8b11601f62d05020aa0fd34b47c24d2 100644 (file)
@@ -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);
         }