]> git.ipfire.org Git - thirdparty/systemd.git/commit
core: Verify inherited FDs are writable for stdout/stderr 39674/head
authorChris Down <chris@chrisdown.name>
Mon, 10 Nov 2025 20:26:10 +0000 (04:26 +0800)
committerChris Down <chris@chrisdown.name>
Wed, 19 Nov 2025 18:02:21 +0000 (02:02 +0800)
commit171ceb4a00294c700c0ba6906a3a3abad846699e
tree300b69d17688b097d4e3732ea63fd738fd3ba83a
parent592c57e586fa5aac78145d689608c487344605db
core: Verify inherited FDs are writable for stdout/stderr

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.
src/core/exec-invoke.c