From fcba1e1a5d556ce7b52101dbd2d1ba4a19469161 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Fri, 5 Jan 2018 11:53:34 +0000 Subject: manager: Find user's current graphical session, not session of caller If (e.g.) gnome-shell is started as a systemd --user unit, it won't be part of the login session. We should instead look through all of the user's sessions until we find the login session, and take that as our session. --- libgdm/Makefile.am | 1 + libgdm/gdm-user-switching.c | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'libgdm') diff --git a/libgdm/Makefile.am b/libgdm/Makefile.am index 88534a54..fadffbec 100644 --- a/libgdm/Makefile.am +++ b/libgdm/Makefile.am @@ -66,6 +66,7 @@ libgdm_la_LDFLAGS = \ $(END_OF_LIST) libgdm_la_LIBADD = \ + $(top_builddir)/common/libgdmcommon.la \ $(LIBGDM_LIBS) \ $(SYSTEMD_LIBS) \ $(END_OF_LIST) diff --git a/libgdm/gdm-user-switching.c b/libgdm/gdm-user-switching.c index 3d4303e3..3a33fcbb 100644 --- a/libgdm/gdm-user-switching.c +++ b/libgdm/gdm-user-switching.c @@ -191,6 +191,7 @@ goto_login_session (GDBusConnection *connection, char *our_session; char *session_id; char *seat_id; + GError *local_error = NULL; ret = FALSE; session_id = NULL; @@ -202,11 +203,8 @@ goto_login_session (GDBusConnection *connection, /* Note that we mostly use free () here, instead of g_free () * since the data allocated is from libsystemd-logind, which * does not use GLib's g_malloc (). */ - - res = sd_pid_get_session (0, &our_session); - if (res < 0) { - g_debug ("failed to determine own session: %s", strerror (-res)); - g_set_error (error, GDM_CLIENT_ERROR, 0, _("Could not identify the current session.")); + if (!gdm_find_display_session_for_uid (getuid (), &our_session, &local_error)) { + g_propagate_prefixed_error (error, local_error, _("Could not identify the current session: ")); return FALSE; } -- cgit v1.2.1