diff options
author | Ray Strode <rstrode@redhat.com> | 2016-02-04 13:36:06 -0500 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2016-02-04 13:40:07 -0500 |
commit | 99eeae91c1f11997521ad3bc016a7b2d23ec7942 (patch) | |
tree | 534f2468fabcb24944c844d27017063ed59293c9 /daemon | |
parent | a5aea71e6747eee020bf8e8a6b944b99d830c75c (diff) | |
download | gdm-99eeae91c1f11997521ad3bc016a7b2d23ec7942.tar.gz |
daemon: support dbus user buses with X sessions
If the dbus user bus was started when the user first
logged in, before the session was started, then that
dbus daemon won't have DISPLAY and XAUTHORITY in its
activation environment.
This means programs activated from that dbus daemon
also won't have DISPLAY and XAUTHORITY in their
activation environments.
This commit changes GDM to explicitly put the two
variables in the activation environment via D-Bus,
rather than sending them into the bus environment
process when launching the bus (since in the case
of the user bus, we don't launch it).
https://bugzilla.gnome.org/show_bug.cgi?id=761568
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/gdm-x-session.c | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/daemon/gdm-x-session.c b/daemon/gdm-x-session.c index 624f67ca..c01cc5ee 100644 --- a/daemon/gdm-x-session.c +++ b/daemon/gdm-x-session.c @@ -378,6 +378,9 @@ spawn_bus (State *state, GSubprocess *subprocess = NULL; GInputStream *input_stream = NULL; GDataInputStream *data_stream = NULL; + GDBusConnection *connection = NULL; + GVariantBuilder *builder = NULL; + GVariant *reply = NULL; GError *error = NULL; const char *bus_env = NULL; char *bus_address_fd_string; @@ -407,9 +410,6 @@ spawn_bus (State *state, arguments = g_ptr_array_new (); launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_NONE); - g_subprocess_launcher_setenv (launcher, "DISPLAY", state->display_name, TRUE); - g_subprocess_launcher_setenv (launcher, "XAUTHORITY", state->auth_file, TRUE); - g_subprocess_launcher_take_fd (launcher, pipe_fds[1], BUS_ADDRESS_FILENO); bus_address_fd_string = g_strdup_printf ("%d", BUS_ADDRESS_FILENO); @@ -462,6 +462,42 @@ spawn_bus (State *state, on_bus_finished, state); + connection = g_dbus_connection_new_for_address_sync (state->bus_address, + G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | + G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION, + NULL, + cancellable, + &error); + + if (connection == NULL) { + g_debug ("could not open connection to session bus: %s", + error->message); + goto out; + } + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ss}")); + g_variant_builder_add (&builder, "{ss}", "DISPLAY", state->display_name); + g_variant_builder_add (&builder, "{ss}", "XAUTHORITY", state->auth_file); + + reply = g_dbus_connection_call_sync (connection, + "org.freedesktop.DBus", + "/org/freedesktop/DBus", + "org.freedesktop.DBus", + "UpdateActivationEnvironment", + g_variant_new ("(@a{ss})", + g_variant_builder_end (&builder)), + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, &error); + + if (reply == NULL) { + g_debug ("could not update activation environment: %s", error->message); + goto out; + } + + g_variant_unref (reply); + g_clear_object (&connection); + is_running = TRUE; out: g_clear_object (&data_stream); |