Blame SOURCES/0011-manager-don-t-bail-if-session-disappears-out-from-un.patch

a1b388
From 67d29b19ff4e53d58879b14c2e79a3bda419576f Mon Sep 17 00:00:00 2001
a1b388
From: Ray Strode <rstrode@redhat.com>
a1b388
Date: Fri, 22 Jun 2018 15:26:03 -0400
a1b388
Subject: [PATCH 11/51] manager: don't bail if session disappears out from
a1b388
 under us
a1b388
a1b388
It's entirely possible for a session returned by
a1b388
sd_seat_get_sessions to disappear immediately after the
a1b388
sd_seat_get_sessions call returns.  This is especially
a1b388
likely at logout time where the session will briefly be
a1b388
in the "closing" state before getting reaped.
a1b388
a1b388
If that happens when we're looking for a greeter session, we
a1b388
stop looking for a greeter session and bail out all confused.
a1b388
a1b388
This commit fixes the confusion by gracefully handling the
a1b388
session disappearing by just proceeding to the next session
a1b388
in the list.
a1b388
---
a1b388
 daemon/gdm-manager.c | 10 ++++++++++
a1b388
 1 file changed, 10 insertions(+)
a1b388
a1b388
diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
a1b388
index a6f13dec7..ede22e771 100644
a1b388
--- a/daemon/gdm-manager.c
a1b388
+++ b/daemon/gdm-manager.c
a1b388
@@ -1349,87 +1349,97 @@ maybe_start_pending_initial_login (GdmManager *manager,
a1b388
         g_free (user_session_seat_id);
a1b388
 }
a1b388
 
a1b388
 static gboolean
a1b388
 get_login_window_session_id (const char  *seat_id,
a1b388
                              char       **session_id)
a1b388
 {
a1b388
         gboolean   ret;
a1b388
         int        res, i;
a1b388
         char     **sessions;
a1b388
         char      *service_id;
a1b388
         char      *service_class;
a1b388
         char      *state;
a1b388
 
a1b388
         res = sd_seat_get_sessions (seat_id, &sessions, NULL, NULL);
a1b388
         if (res < 0) {
a1b388
                 g_debug ("Failed to determine sessions: %s", strerror (-res));
a1b388
                 return FALSE;
a1b388
         }
a1b388
 
a1b388
         if (sessions == NULL || sessions[0] == NULL) {
a1b388
                 *session_id = NULL;
a1b388
                 ret = FALSE;
a1b388
                 goto out;
a1b388
         }
a1b388
 
a1b388
         for (i = 0; sessions[i]; i ++) {
a1b388
 
a1b388
                 res = sd_session_get_class (sessions[i], &service_class);
a1b388
                 if (res < 0) {
a1b388
+                        if (res == -ENOENT) {
a1b388
+                                free (service_class);
a1b388
+                                continue;
a1b388
+                        }
a1b388
+
a1b388
                         g_debug ("failed to determine class of session %s: %s", sessions[i], strerror (-res));
a1b388
                         ret = FALSE;
a1b388
                         goto out;
a1b388
                 }
a1b388
 
a1b388
                 if (strcmp (service_class, "greeter") != 0) {
a1b388
                         free (service_class);
a1b388
                         continue;
a1b388
                 }
a1b388
 
a1b388
                 free (service_class);
a1b388
 
a1b388
                 ret = sd_session_get_state (sessions[i], &state);
a1b388
                 if (ret < 0) {
a1b388
+                        if (res == -ENOENT)
a1b388
+                                continue;
a1b388
+
a1b388
                         g_debug ("failed to determine state of session %s: %s", sessions[i], strerror (-res));
a1b388
                         ret = FALSE;
a1b388
                         goto out;
a1b388
                 }
a1b388
 
a1b388
                 if (g_strcmp0 (state, "closing") == 0) {
a1b388
                         free (state);
a1b388
                         continue;
a1b388
                 }
a1b388
                 free (state);
a1b388
 
a1b388
                 res = sd_session_get_service (sessions[i], &service_id);
a1b388
                 if (res < 0) {
a1b388
+                        if (res == -ENOENT)
a1b388
+                                continue;
a1b388
                         g_debug ("failed to determine service of session %s: %s", sessions[i], strerror (-res));
a1b388
                         ret = FALSE;
a1b388
                         goto out;
a1b388
                 }
a1b388
 
a1b388
                 if (strcmp (service_id, "gdm-launch-environment") == 0) {
a1b388
                         *session_id = g_strdup (sessions[i]);
a1b388
                         ret = TRUE;
a1b388
 
a1b388
                         free (service_id);
a1b388
                         goto out;
a1b388
                 }
a1b388
 
a1b388
                 free (service_id);
a1b388
         }
a1b388
 
a1b388
         *session_id = NULL;
a1b388
         ret = FALSE;
a1b388
 
a1b388
 out:
a1b388
         if (sessions) {
a1b388
                 for (i = 0; sessions[i]; i ++) {
a1b388
                         free (sessions[i]);
a1b388
                 }
a1b388
 
a1b388
                 free (sessions);
a1b388
         }
a1b388
 
a1b388
         return ret;
a1b388
 }
a1b388
-- 
a1b388
2.27.0
a1b388