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

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