]> git.ipfire.org Git - thirdparty/systemd.git/commit
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)
commit3f91ffe0fe900660a8c073ec54b3951e33b5c74c
treef39a72138efc9e920730ddc8756b8487ff5d0543
parent5b0e262f451af6b5cab0fdb239512c3ae89c25d0
parent171ceb4a00294c700c0ba6906a3a3abad846699e
core: Verify inherited FDs are writable for stdout/stderr (#39674)

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.