Skip to content

Don't let dbus-daemon and its subprocesses inherit unnecessary fds

Simon McVittie requested to merge smcv/dbus:dbus-daemon-inherited-fds into master

This should avoid test failures under CMake in which the dbus-daemon inherits an unwanted fd from CMake's test framework, causing the close-on-exec check before executing activated services to fail.

The dbus-daemon now marks all fds that it inherits, except for its stdin, stdout and stderr, to be closed on exec. For completeness, the dbus-daemons run by dbus-run-session and dbus-launch also now inherit stdin, stdout, stderr and the pipes used to communicate with their callers, but nothing else.

To help to debug similar issues, in operating systems where /proc/self/fd works like it does on Linux (Linux itself, and FreeBSD with Linux /proc emulation) I've also expanded the open-fds check to give us a clue about the fd that was leaked or opened incorrectly.

Merge request reports