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
This commit is contained in:
Iain Lane 2018-07-09 10:20:47 +01:00 committed by Iain Lane
parent 90a68f3118
commit 89162a90aa

View File

@ -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)
{