Search
SailfishOS Open Build Service
>
Projects
>
home:sfietkonstantin
:
sailfish
:
experiments
>
polkit
> seatedsession.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File seatedsession.patch of Package polkit
diff -ur a/src/polkitbackend/polkitbackendsessionmonitor-systemd.c b/src/polkitbackend/polkitbackendsessionmonitor-systemd.c --- a/src/polkitbackend/polkitbackendsessionmonitor-systemd.c 2015-06-19 22:31:02.000000000 +0200 +++ b/src/polkitbackend/polkitbackendsessionmonitor-systemd.c 2016-08-09 07:38:36.352980158 +0200 @@ -298,6 +298,33 @@ return ret; } +static int +fetch_seated_session(uid_t uid, char **session_id) +{ + int i = 0; + char **sessions = NULL; + char *seat = NULL; + int count = sd_uid_get_sessions (uid, FALSE, &sessions); + + for (i = 0; i < count; ++i) + { + if (*session_id == NULL && sessions[i] != NULL) + { + seat = NULL; + sd_session_get_seat (sessions[i], &seat); + if (seat != NULL) + { + *session_id = g_strdup(sessions[i]); + } + free(seat); + } + free(sessions[i]); + } + free(sessions); + + return *session_id != NULL ? 0 : -1; +} + /** * polkit_backend_session_monitor_get_session_for_subject: * @monitor: A #PolkitBackendSessionMonitor. @@ -318,9 +345,7 @@ PolkitSubject *session = NULL; char *session_id = NULL; pid_t pid; -#if HAVE_SD_UID_GET_DISPLAY uid_t uid; -#endif if (POLKIT_IS_UNIX_PROCESS (subject)) process = POLKIT_UNIX_PROCESS (subject); /* We already have a process */ @@ -351,17 +376,24 @@ goto out; } -#if HAVE_SD_UID_GET_DISPLAY - /* Now do process -> uid -> graphical session (systemd version 213)*/ if (sd_pid_get_owner_uid (pid, &uid) < 0) goto out; +#if HAVE_SD_UID_GET_DISPLAY + /* Now do process -> uid -> graphical session (systemd version 213)*/ + if (sd_uid_get_display (uid, &session_id) >= 0) { session = polkit_unix_session_new (session_id); goto out; } #endif + /* Now do process -> uid -> seated session if there is one (sailfish OS)*/ + if (fetch_seated_session (uid, &session_id) >= 0) + { + session = polkit_unix_session_new (session_id); + goto out; + } out: free (session_id);