diff options
author | Iain Lane <iainl@gnome.org> | 2018-07-09 10:20:47 +0100 |
---|---|---|
committer | Iain Lane <iain@orangesquash.org.uk> | 2018-07-10 08:43:35 +0000 |
commit | 89162a90aadce266a17fc67aa03162e473adb2e0 (patch) | |
tree | d6e1b7dff7c35ddd47f9834bced4641c5296516e | |
parent | 90a68f3118e39c1f93430a129a7605fce54f88ae (diff) | |
download | mutter-89162a90aadce266a17fc67aa03162e473adb2e0.tar.gz |
launcher: First check if we are in a login session
For mutter developers we still want to support running from a VT, which
will be in a different login session.
Fixes #218
-rw-r--r-- | src/backends/native/meta-launcher.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/backends/native/meta-launcher.c b/src/backends/native/meta-launcher.c index 15cad0d40..fb12b0cf5 100644 --- a/src/backends/native/meta-launcher.c +++ b/src/backends/native/meta-launcher.c @@ -79,6 +79,29 @@ find_systemd_session (gchar **session_id, g_assert (session_id != NULL); g_assert (error == NULL || *error == NULL); + /* 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. */ + saved_errno = sd_pid_get_session (0, &local_session_id); + if (saved_errno < 0) + { + if (saved_errno != -ENODATA) + { + g_set_error (error, + G_IO_ERROR, + G_IO_ERROR_NOT_FOUND, + "Failed to get session by pid for user %d (%s)", + getuid (), + g_strerror (-saved_errno)); + return FALSE; + } + } + else + { + *session_id = g_steal_pointer (&local_session_id); + return TRUE; + } + saved_errno = sd_uid_get_display (getuid (), &local_session_id); if (saved_errno < 0) { |