]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: Verify inherited FDs are writable for stdout/stderr (#39674)
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 19 Nov 2025 23:19:46 +0000 (08:19 +0900)
committerGitHub <noreply@github.com>
Wed, 19 Nov 2025 23:19:46 +0000 (08:19 +0900)
When inheriting file descriptors for stdout/stderr (either from stdin or
when making stderr inherit from stdout), we previously just assumed they
would be writable and dup'd them. This could lead to broken setups if
the inherited FD was actually opened read-only.

Before dup'ing any inherited FDs to stdout/stderr, verify they are
actually writable using the new fd_is_writable() helper. If not, fall
back to /dev/null (or reopen the terminal in the TTY case) with a
warning, rather than silently creating a broken setup where output
operations would fail.


Trivial merge