Drop chdir("/") in dbus-launch
Submitted by David King
Assigned to D-Bus Maintainers
Link to original bug (#106987)
Description
In RHEL 7, Paul Gozart came across some unexpected behaviour in gedit when run as a regular user, where the save dialog used the root path ("/") as the default location. This was traced down by Ray Strode to gedit in newer RHEL 7 versions being launched by dbus activation (as most GNOME applications are, if they use GApplication), and the dbus-daemon used for the session bus in RHEL being launched with dbus-launch (by gnome-session, as systemd is not used as a user session manager in RHEL 7).
There is a chdir("/") call in dbus-launch with the following justification:
/* We chdir ("/") since we are persistent and daemon-like, and fork
- again so dbus-launch can reap the parent. However, we don't
- setsid() or close fd 0 because the idea is to remain attached
- to the tty and the X server in order to kill the message bus
- when the session ends. */
Arguably, this is not the best behaviour for a tool that is only used to run session buses, which are scoped to the lifetime of the user's session (with some exceptions, of course), and given the pervasive use of dbus-launch by session managers to start dbus-daemon as a session bus, I think that it is best to drop the chdir() call entirely.
Version: git master