From a149d37ff3d425703d887d5216441cf86611ef24 Mon Sep 17 00:00:00 2001 From: David King Date: Thu, 21 Jun 2018 11:20:00 +0100 Subject: [PATCH] dbus-launch: drop chdir("/") The intention with chdir("/") was to make the behaviour of dbus-daemon when used as a session bus "persistent and daemon-like". However, applications that use dbus activation inherit the working directory, and do not act like other applications from the point of view of the user. An example wouold be the default directory in a save dialog being the root path. As a session bus is only persistent in a user session, it makes sense for the working directory to be unchanged by dbus-launch. Signed-off-by: David King Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106987 Bug-RedHat: https://bugzilla.redhat.com/show_bug.cgi?id=1470310 --- tools/dbus-launch.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 425914a1..e84415ba 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -622,20 +622,12 @@ babysit (int exit_with_session, verbose ("babysitting, exit_with_session = %d, child_pid = %ld, read_bus_pid_fd = %d\n", exit_with_session, (long) child_pid, read_bus_pid_fd); - /* 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. + /* We 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. */ - if (chdir ("/") < 0) - { - fprintf (stderr, "Could not change to root directory: %s\n", - strerror (errno)); - exit (1); - } - flags = DBUS_FORCE_STDOUT_NULL; if (!exit_with_session) -- 2.17.1