[mutter] launcher: Use $XDG_SESSION_ID if available
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] launcher: Use $XDG_SESSION_ID if available
- Date: Mon, 24 Jan 2022 17:55:28 +0000 (UTC)
commit 8ebdae809222af3c1ea99a0296a59bdaaa6d977b
Author: Sebastian Wick <sebastian wick redhat com>
Date: Mon Jan 24 17:31:32 2022 +0100
launcher: Use $XDG_SESSION_ID if available
In some cases mutter is started in the user scope from a TTY (for
example using toolbox). Using sd_pid_get_session fails because it's not
in the session scope so it falls back to the primary session
(sd_uid_get_display). We want to start mutter on the TTY we started
mutter on however. Instead of relying on the scope to figure out the
correct session we first look at $XDG_SESSION_ID which is set by
systemd_pam.so.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2254>
src/backends/native/meta-launcher.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
---
diff --git a/src/backends/native/meta-launcher.c b/src/backends/native/meta-launcher.c
index 2d2f14dcf5..e968baeed8 100644
--- a/src/backends/native/meta-launcher.c
+++ b/src/backends/native/meta-launcher.c
@@ -72,10 +72,29 @@ find_systemd_session (gchar **session_id,
g_auto (GStrv) sessions = NULL;
int n_sessions;
int saved_errno;
+ const char *xdg_session_id = NULL;
g_assert (session_id != NULL);
g_assert (error == NULL || *error == NULL);
+ xdg_session_id = g_getenv ("XDG_SESSION_ID");
+ if (xdg_session_id)
+ {
+ saved_errno = sd_session_is_active (xdg_session_id);
+ if (saved_errno < 0)
+ {
+ g_set_error (error,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_FOUND,
+ "Failed to get status of XDG_SESSION_ID session (%s)",
+ g_strerror (-saved_errno));
+ return FALSE;
+ }
+
+ *session_id = g_strdup (xdg_session_id);
+ return TRUE;
+ }
+
/* if we are in a logind session, we can trust that value, so use it. This
* happens for example when you run mutter directly from a VT but when
* systemd starts us we will not be in a logind session. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]