Blob Blame History Raw
From 3969532fd960915ddf835e4076489334c6264cf9 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Wed, 1 Aug 2018 15:46:11 -0400
Subject: [PATCH 04/48] manager: make get_login_window_session_id fail if no
 login screen

Right now we oddly succeed from get_login_window_session_id
if we can't find a login window.

None of the caller expect that, so fail instead.
---
 daemon/gdm-manager.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
index e44b94373..a9d5628ea 100644
--- a/daemon/gdm-manager.c
+++ b/daemon/gdm-manager.c
@@ -1372,113 +1372,113 @@ maybe_start_pending_initial_login (GdmManager *manager,
                       NULL);
 
         if (g_strcmp0 (greeter_seat_id, user_session_seat_id) == 0) {
                 start_user_session (manager, operation);
                 manager->priv->initial_login_operation = NULL;
         }
 
         g_free (greeter_seat_id);
         g_free (user_session_seat_id);
 }
 
 static gboolean
 get_login_window_session_id (const char  *seat_id,
                              char       **session_id)
 {
         gboolean   ret;
         int        res, i;
         char     **sessions;
         char      *service_id;
         char      *service_class;
         char      *state;
 
         res = sd_seat_get_sessions (seat_id, &sessions, NULL, NULL);
         if (res < 0) {
                 g_debug ("Failed to determine sessions: %s", strerror (-res));
                 return FALSE;
         }
 
         if (sessions == NULL || sessions[0] == NULL) {
                 *session_id = NULL;
-                ret = TRUE;
+                ret = FALSE;
                 goto out;
         }
 
         for (i = 0; sessions[i]; i ++) {
 
                 res = sd_session_get_class (sessions[i], &service_class);
                 if (res < 0) {
                         g_debug ("failed to determine class of session %s: %s", sessions[i], strerror (-res));
                         ret = FALSE;
                         goto out;
                 }
 
                 if (strcmp (service_class, "greeter") != 0) {
                         free (service_class);
                         continue;
                 }
 
                 free (service_class);
 
                 ret = sd_session_get_state (sessions[i], &state);
                 if (ret < 0) {
                         g_debug ("failed to determine state of session %s: %s", sessions[i], strerror (-res));
                         ret = FALSE;
                         goto out;
                 }
 
                 if (g_strcmp0 (state, "closing") == 0) {
                         free (state);
                         continue;
                 }
                 free (state);
 
                 res = sd_session_get_service (sessions[i], &service_id);
                 if (res < 0) {
                         g_debug ("failed to determine service of session %s: %s", sessions[i], strerror (-res));
                         ret = FALSE;
                         goto out;
                 }
 
                 if (strcmp (service_id, "gdm-launch-environment") == 0) {
                         *session_id = g_strdup (sessions[i]);
                         ret = TRUE;
 
                         free (service_id);
                         goto out;
                 }
 
                 free (service_id);
         }
 
         *session_id = NULL;
-        ret = TRUE;
+        ret = FALSE;
 
 out:
         if (sessions) {
                 for (i = 0; sessions[i]; i ++) {
                         free (sessions[i]);
                 }
 
                 free (sessions);
         }
 
         return ret;
 }
 
 static void
 activate_login_window_session_on_seat (GdmManager *self,
                                        const char *seat_id)
 {
         char *session_id;
 
         if (!get_login_window_session_id (seat_id, &session_id)) {
                 return;
         }
 
         activate_session_id (self, seat_id, session_id);
 }
 
 static void
 maybe_activate_other_session (GdmManager *self,
                               GdmDisplay *old_display)
 {
-- 
2.26.0