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

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