Systemd/src/libsystemd
Lennart Poettering 7fe2903c23 fd-util: move certain fds above fd #2 (#8129)
This adds some paranoia code that moves some of the fds we allocate for
longer periods of times to fds > 2 if they are allocated below this
boundary. This is a paranoid safety thing, in order to avoid that
external code might end up erroneously use our fds under the assumption
they were valid stdin/stdout/stderr. Think: some app closes
stdin/stdout/stderr and then invokes 'fprintf(stderr, …' which causes
writes on our fds.

This both adds the helper to do the moving as well as ports over a
number of users to this new logic. Since we don't want to litter all our
code with invocations of this I tried to strictly focus on fds we keep
open for long periods of times only and only in code that is frequently
loaded into foreign programs (under the assumptions that in our own
codebase we are smart enough to always keep stdin/stdout/stderr
allocated to avoid this pitfall). Specifically this means all code used
by NSS and our sd-xyz API:

1. our logging APIs
2. sd-event
3. sd-bus
4. sd-resolve
5. sd-netlink

This changed was inspired by this:

https://github.com/systemd/systemd/issues/8075#issuecomment-363689755

This shows that apparently IRL there are programs that do close
stdin/stdout/stderr, and we should accomodate for that.

Note that this won't fix any bugs, this just makes sure that buggy
programs are less likely to interfere with out own code.
2018-02-09 17:53:28 +01:00
..
sd-bus fd-util: move certain fds above fd #2 (#8129) 2018-02-09 17:53:28 +01:00
sd-daemon Merge pull request #7816 from poettering/chase-pid 2018-01-15 14:14:34 +04:00
sd-device sd-device: support the case that /sys is a symlink 2018-01-08 01:36:08 +09:00
sd-event fd-util: move certain fds above fd #2 (#8129) 2018-02-09 17:53:28 +01:00
sd-hwdb Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
sd-id128 log: minimize includes in log.h 2018-01-11 14:44:31 +01:00
sd-login io-util: make flush_fd() return how many bytes where flushed 2018-01-05 13:55:08 +01:00
sd-netlink fd-util: move certain fds above fd #2 (#8129) 2018-02-09 17:53:28 +01:00
sd-network tree-wide: make use of new STRLEN() macro everywhere (#7639) 2017-12-14 19:02:29 +01:00
sd-path Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
sd-resolve fd-util: move certain fds above fd #2 (#8129) 2018-02-09 17:53:28 +01:00
sd-utf8 Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
libsystemd.pc.in Add SPDX license headers to various assorted files 2017-11-19 19:08:15 +01:00
libsystemd.sym Add fd close support to sd_event_source 2018-01-24 17:57:27 +01:00
meson.build sd-bus: drop bloom stuff, it's not needed anymore since kdbus is gone 2018-01-11 14:44:31 +01:00