Blob Blame History Raw
From 454a3daad5148a8ef30cb298af82aa0713e73af7 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Mon, 18 Jun 2018 12:33:51 +0200
Subject: [PATCH 06/51] manager: gracefully handle the case of no session for
 login window

get_login_window_session_id() will return TRUE with session_id=NULL when
there's no session. This restults in an assertion failure on
constructing the o.fd.login1.Manager.ActivateSessionOnSeat() arguments:

  GLib: g_variant_new_string: assertion 'string != NULL' failed
---
 daemon/gdm-manager.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
index 71f55ec65..7a5554e9d 100644
--- a/daemon/gdm-manager.c
+++ b/daemon/gdm-manager.c
@@ -1448,62 +1448,64 @@ get_login_window_session_id (const char  *seat_id,
                 }
 
                 free (service_id);
         }
 
         *session_id = NULL;
         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);
-        g_free (session_id);
+        if (session_id) {
+                activate_session_id (self, seat_id, session_id);
+                g_free (session_id);
+        }
 }
 
 static void
 maybe_activate_other_session (GdmManager *self,
                               GdmDisplay *old_display)
 {
         char *seat_id = NULL;
         char *session_id;
         int ret;
 
         g_object_get (G_OBJECT (old_display),
                       "seat-id", &seat_id,
                       NULL);
 
         ret = sd_seat_get_active (seat_id, &session_id, NULL);
 
         if (ret == 0) {
                 GdmDisplay *display;
 
                 display = gdm_display_store_find (self->priv->display_store,
                                                   lookup_by_session_id,
                                                   (gpointer) session_id);
 
                 if (display == NULL) {
                         activate_login_window_session_on_seat (self, seat_id);
                 }
         }
 
         g_free (seat_id);
 }
-- 
2.27.0