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)
This commit is contained in:
Mike Yuan
2024-03-26 18:57:08 +08:00
parent 469ff6b40e
commit 07ff03d6b2
2 changed files with 4 additions and 1 deletions

View 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);

View 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);
}