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

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