]> git.ipfire.org Git - thirdparty/systemd.git/commit
core/execute: refactor creation of array with fds to keep during execution
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 16 Sep 2020 15:38:26 +0000 (17:38 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 14 Oct 2020 16:29:25 +0000 (18:29 +0200)
commit1da37e58ffb2f8bfa129a550c09bf2d458d7c782
treead5ba666f796f149b47783a07c9b507f8e2978b0
parentfc8bc57f6b25266ab52166c917b39a3abf2fa54d
core/execute: refactor creation of array with fds to keep during execution

We close fds in two phases, first some and then the some more. When passing
a list of fds to exclude from closing to the closing function, we would
pass some in an array and the rest as separate arguments. For the fds which
should be excluded in both closing phases, let's always create the array
and put the relevant fds there. This has the advantage that if more fds to
exclude in both phases are added later, we don't need to add more positional
arguments.

The list passed to setup_pam() is not changed. I think we could pass more fds
to close there, but I'm leaving that unchanged.

The setting of FD_CLOEXEC on an already open fds is dropped. The fd is opened
in service_allocate_exec_fd() and there is no reason to suspect that it might
have been opened incorrectly. If some rogue code is unsetting our FD_CLOEXEC
bits, then it might flip any fd, no reason to single this one out.
src/core/execute.c