@@ -1,68 +1,7 @@
-diff -ur a/src/polkit/polkitunixsession-systemd.c b/src/polkit/polkitunixsession-systemd.c
---- a/src/polkit/polkitunixsession-systemd.c 2014-01-14 23:42:25.000000000 +0100
-+++ b/src/polkit/polkitunixsession-systemd.c 2016-08-08 09:40:32.082755244 +0200
-@@ -443,6 +443,32 @@
- subject_iface->exists_sync = polkit_unix_session_exists_sync;
- }
-
-+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) {
-+ if (sessions[i] != NULL) {
-+ if (sd_session_get_seat (sessions[i], &seat) >= 0) {
-+ if (seat != NULL) {
-+ *session_id = g_strdup(sessions[i]);
-+ free(seat);
-+ }
-+ }
-+ }
-+ }
-+ free(sessions[i]);
-+ }
-+ free(sessions);
-+
-+ return *session_id != NULL ? 0 : -1;
-+}
-+
- static gboolean
- polkit_unix_session_initable_init (GInitable *initable,
- GCancellable *cancellable,
-@@ -451,6 +477,7 @@
- PolkitUnixSession *session = POLKIT_UNIX_SESSION (initable);
- gboolean ret = FALSE;
- char *s;
-+ uid_t uid;
-
- if (session->session_id != NULL)
- {
-@@ -463,6 +490,16 @@
- {
- session->session_id = g_strdup (s);
- free (s);
-+ ret = TRUE;
-+ goto out;
-+ }
-+ if (sd_pid_get_owner_uid (pid, &uid) < 0)
-+ goto out;
-+
-+ if (fetch_seated_session (uid, &s)
-+ {
-+ session->session_id = g_strdup (s);
-+ free (s);
- ret = TRUE;
- goto out;
- }
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-08 09:40:07.903586740 +0200
-@@ -298,6 +298,32 @@
++++ b/src/polkitbackend/polkitbackendsessionmonitor-systemd.c 2016-08-08 20:23:53.169543245 +0200
+@@ -298,6 +298,33 @@
return ret;
}
@@ -74,19 +13,20 @@
+ char *seat = NULL;
+ int count = sd_uid_get_sessions (uid, FALSE, &sessions);
+
-+ for (i = 0; i < count; ++i) {
-+ if (*session_id == NULL) {
-+ if (sessions[i] != NULL) {
-+ if (sd_session_get_seat (sessions[i], &seat) >= 0) {
-+ if (seat != NULL) {
-+ *session_id = g_strdup(sessions[i]);
-+ free(seat);
-+ }
++ 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[i]);
-+ }
+ free(sessions);
+
+ return *session_id != NULL ? 0 : -1;
@@ -95,7 +35,7 @@
/**
* polkit_backend_session_monitor_get_session_for_subject:
* @monitor: A #PolkitBackendSessionMonitor.
-@@ -318,9 +344,7 @@
+@@ -318,9 +345,7 @@
PolkitSubject *session = NULL;
char *session_id = NULL;
pid_t pid;
@@ -105,7 +45,7 @@
if (POLKIT_IS_UNIX_PROCESS (subject))
process = POLKIT_UNIX_PROCESS (subject); /* We already have a process */
-@@ -362,6 +386,12 @@
+@@ -362,6 +387,12 @@
goto out;
}
#endif
|