Blame SOURCES/0004-local-display-factory-Don-t-crash-if-Xorg-and-Waylan.patch

c0d9a4
From dfca67899ea33da08d3aa9e84c1b4487991adad0 Mon Sep 17 00:00:00 2001
523f1e
From: Ray Strode <rstrode@redhat.com>
523f1e
Date: Thu, 7 Oct 2021 15:34:27 -0400
523f1e
Subject: [PATCH 4/4] local-display-factory: Don't crash if Xorg and Wayland
523f1e
 are both unavailable
523f1e
523f1e
At the moment if Wayland doesn't work, the login screen will fall back
523f1e
to Xorg, and if Xorg doesn't work the login screen will fall back to
523f1e
Wayland.
523f1e
523f1e
But if the fall back choice is disabled explicitly, GDM will just crash.
523f1e
523f1e
This commit fixes the crash.
523f1e
523f1e
Closes: https://gitlab.gnome.org/GNOME/gdm/-/issues/739
523f1e
---
523f1e
 daemon/gdm-local-display-factory.c | 9 +++++++--
523f1e
 1 file changed, 7 insertions(+), 2 deletions(-)
523f1e
523f1e
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
523f1e
index eba38671..120847f9 100644
523f1e
--- a/daemon/gdm-local-display-factory.c
523f1e
+++ b/daemon/gdm-local-display-factory.c
523f1e
@@ -651,62 +651,67 @@ ensure_display_for_seat (GdmLocalDisplayFactory *factory,
523f1e
         gdm_settings_direct_get_boolean (GDM_KEY_XORG_ENABLE, &xorg_enabled);
523f1e
 
523f1e
         preferred_display_server = get_preferred_display_server (factory);
523f1e
 
523f1e
         if (g_strcmp0 (preferred_display_server, "none") == 0) {
523f1e
                g_debug ("GdmLocalDisplayFactory: Preferred display server is none, so not creating display");
523f1e
                return;
523f1e
         }
523f1e
 
523f1e
         ret = sd_seat_can_graphical (seat_id);
523f1e
 
523f1e
         if (ret < 0) {
523f1e
                 g_critical ("Failed to query CanGraphical information for seat %s", seat_id);
523f1e
                 return;
523f1e
         }
523f1e
 
523f1e
         if (ret == 0) {
523f1e
                 g_debug ("GdmLocalDisplayFactory: System doesn't currently support graphics");
523f1e
                 seat_supports_graphics = FALSE;
523f1e
         } else {
523f1e
                 g_debug ("GdmLocalDisplayFactory: System supports graphics");
523f1e
                 seat_supports_graphics = TRUE;
523f1e
         }
523f1e
 
523f1e
         if (g_strcmp0 (seat_id, "seat0") == 0) {
523f1e
                 is_seat0 = TRUE;
523f1e
 
523f1e
                 falling_back = factory->num_failures > 0;
523f1e
                 session_types = gdm_local_display_factory_get_session_types (factory, falling_back);
523f1e
 
523f1e
-                g_debug ("GdmLocalDisplayFactory: New displays on seat0 will use %s%s",
523f1e
-                         session_types[0], falling_back? " fallback" : "");
523f1e
+                if (session_types == NULL) {
523f1e
+                        g_debug ("GdmLocalDisplayFactory: Both Wayland and Xorg are unavailable");
523f1e
+                        seat_supports_graphics = FALSE;
523f1e
+                } else {
523f1e
+                        g_debug ("GdmLocalDisplayFactory: New displays on seat0 will use %s%s",
523f1e
+                                 session_types[0], falling_back? " fallback" : "");
523f1e
+                }
523f1e
         } else {
523f1e
                 is_seat0 = FALSE;
523f1e
 
523f1e
                 g_debug ("GdmLocalDisplayFactory: New displays on seat %s will use X11 fallback", seat_id);
523f1e
                 /* Force legacy X11 for all auxiliary seats */
523f1e
                 seat_supports_graphics = TRUE;
523f1e
                 session_types = g_strdupv ((char **) legacy_session_types);
523f1e
         }
523f1e
 
523f1e
         /* For seat0, we have a fallback logic to still try starting it after
523f1e
          * SEAT0_GRAPHICS_CHECK_TIMEOUT seconds. i.e. we simply continue even if
523f1e
          * CanGraphical is unset.
523f1e
          * This is ugly, but it means we'll come up eventually in some
523f1e
          * scenarios where no master device is present.
523f1e
          * Note that we'll force an X11 fallback even though there might be
523f1e
          * cases where an wayland capable device is present and simply not marked as
523f1e
          * master-of-seat. In these cases, this should likely be fixed in the
523f1e
          * udev rules.
523f1e
          *
523f1e
          * At the moment, systemd always sets CanGraphical for non-seat0 seats.
523f1e
          * This is because non-seat0 seats are defined by having master-of-seat
523f1e
          * set. This means we can avoid the fallback check for non-seat0 seats,
523f1e
          * which simplifies the code.
523f1e
          */
523f1e
         if (is_seat0) {
523f1e
                 if (!seat_supports_graphics) {
523f1e
                         if (!factory->seat0_graphics_check_timed_out) {
523f1e
                                 if (factory->seat0_graphics_check_timeout_id == 0) {
523f1e
                                         g_debug ("GdmLocalDisplayFactory: seat0 doesn't yet support graphics.  Waiting %d seconds to try again.", SEAT0_GRAPHICS_CHECK_TIMEOUT);
523f1e
                                         factory->seat0_graphics_check_timeout_id = g_timeout_add_seconds (SEAT0_GRAPHICS_CHECK_TIMEOUT,
523f1e
-- 
523f1e
2.34.1
523f1e