]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/libsystemd/sd-bus/bus-socket.c
tree-wide: introduce new safe_fork() helper and port everything over
authorLennart Poettering <lennart@poettering.net>
Fri, 22 Dec 2017 12:08:14 +0000 (13:08 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 25 Dec 2017 10:48:21 +0000 (11:48 +0100)
commit4c253ed1cae8b4df72ce1353ee826a4fae399e25
tree5fc52b199a402b4ddaae0e3005fa85cc610c377f
parentd8caff6db672ab0f2d8064c61f5ef0e8e8d288ca
tree-wide: introduce new safe_fork() helper and port everything over

This adds a new safe_fork() wrapper around fork() and makes use of it
everywhere. The new wrapper does a couple of things we previously did
manually and separately in a safer, more correct and automatic way:

1. Optionally resets signal handlers/mask in the child

2. Sets a name on all processes we fork off right after forking off (and
   the patch assigns useful names for all processes we fork off now,
   following a systematic naming scheme: always enclosed in () – in order
   to indicate that these are not proper, exec()ed processes, but only
   forked off children, and if the process is long-running with only our
   own code, without execve()'ing something else, it gets am "sd-" prefix.)

3. Optionally closes all file descriptors in the child

4. Optionally sets a PR_SET_DEATHSIG to SIGTERM in the child, in a safe
   way so that the parent dying before this happens being handled
   safely.

5. Optionally reopens the logs

6. Optionally connects stdin/stdout/stderr to /dev/null

7. Debug logs about the forked off processes.
42 files changed:
src/activate/activate.c
src/basic/async.c
src/basic/calendarspec.c
src/basic/exec-util.c
src/basic/process-util.c
src/basic/process-util.h
src/basic/terminal-util.c
src/basic/time-util.c
src/basic/util.c
src/core/execute.c
src/core/shutdown.c
src/core/socket.c
src/core/umount.c
src/core/unit.c
src/core/unit.h
src/coredump/coredumpctl.c
src/delta/delta.c
src/fsck/fsck.c
src/import/import-common.c
src/import/importd.c
src/import/pull-common.c
src/journal-remote/journal-remote.c
src/libsystemd/sd-bus/bus-container.c
src/libsystemd/sd-bus/bus-socket.c
src/login/inhibit.c
src/machine/image-dbus.c
src/machine/machine-dbus.c
src/machine/machined-dbus.c
src/nspawn/nspawn-setuid.c
src/nspawn/nspawn-stub-pid1.c
src/partition/makefs.c
src/quotacheck/quotacheck.c
src/remount-fs/remount-fs.c
src/shared/logs-show.c
src/shared/machine-pool.c
src/shared/pager.c
src/sulogin-shell/sulogin-shell.c
src/systemctl/systemctl.c
src/test/test-process-util.c
src/tty-ask-password-agent/tty-ask-password-agent.c
src/udev/udev-event.c
src/vconsole/vconsole-setup.c