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

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