Blame SOURCES/0016-local-display-factory-don-t-start-two-greeters-at-st.patch

400dab
From e5bf6d78ff8f54bbb74e572f05ccbf1c0df24017 Mon Sep 17 00:00:00 2001
400dab
From: Ray Strode <rstrode@redhat.com>
400dab
Date: Tue, 7 Aug 2018 13:55:06 -0400
400dab
Subject: [PATCH 16/51] local-display-factory: don't start two greeters at
400dab
 startup
400dab
400dab
commit c0188a7030 added some complex code for starting
400dab
the login screen when the user switches to the initial
400dab
VT if nothing is running on that VT.
400dab
400dab
The problem is, we get a VT change event on that VT as
400dab
part of the start up process.
400dab
400dab
This leads to an additional greeter getting started.
400dab
400dab
This commit adds a check to side step the new code during
400dab
startup.
400dab
400dab
Closes: https://gitlab.gnome.org/GNOME/gdm/issues/409
400dab
---
400dab
 daemon/gdm-local-display-factory.c | 6 ++++++
400dab
 1 file changed, 6 insertions(+)
400dab
400dab
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
400dab
index 2a2259f2a..9f377ba9a 100644
400dab
--- a/daemon/gdm-local-display-factory.c
400dab
+++ b/daemon/gdm-local-display-factory.c
400dab
@@ -600,60 +600,66 @@ on_vt_changed (GIOChannel    *source,
400dab
                 g_autoptr (GError) error = NULL;
400dab
                 status = g_io_channel_read_line (source, &tty_of_active_vt, NULL, NULL, &error);
400dab
 
400dab
                 if (error != NULL) {
400dab
                         g_warning ("could not read active VT from kernel: %s", error->message);
400dab
                 }
400dab
                 switch (status) {
400dab
                         case G_IO_STATUS_ERROR:
400dab
                             return G_SOURCE_REMOVE;
400dab
                         case G_IO_STATUS_EOF:
400dab
                             return G_SOURCE_REMOVE;
400dab
                         case G_IO_STATUS_AGAIN:
400dab
                             return G_SOURCE_CONTINUE;
400dab
                         case G_IO_STATUS_NORMAL:
400dab
                             break;
400dab
                 }
400dab
         }
400dab
 
400dab
         if ((condition & G_IO_ERR) || (condition & G_IO_HUP)) {
400dab
                 g_debug ("GdmLocalDisplayFactory: kernel hung up active vt watch");
400dab
                 return G_SOURCE_REMOVE;
400dab
         }
400dab
 
400dab
         if (tty_of_active_vt == NULL) {
400dab
                 g_debug ("GdmLocalDisplayFactory: unable to read active VT from kernel");
400dab
                 return G_SOURCE_CONTINUE;
400dab
         }
400dab
 
400dab
         g_strchomp (tty_of_active_vt);
400dab
 
400dab
+        /* don't do anything if we're on the same VT we were before */
400dab
+        if (g_strcmp0 (tty_of_active_vt, factory->priv->tty_of_active_vt) == 0) {
400dab
+                g_debug ("GdmLocalDisplayFactory: VT changed to the same VT, ignoring");
400dab
+                return G_SOURCE_CONTINUE;
400dab
+        }
400dab
+
400dab
         tty_of_previous_vt = g_steal_pointer (&factory->priv->tty_of_active_vt);
400dab
         factory->priv->tty_of_active_vt = g_steal_pointer (&tty_of_active_vt);
400dab
 
400dab
         /* don't do anything at start up */
400dab
         if (tty_of_previous_vt == NULL) {
400dab
                 g_debug ("GdmLocalDisplayFactory: VT is %s at startup",
400dab
                          factory->priv->tty_of_active_vt);
400dab
                 return G_SOURCE_CONTINUE;
400dab
         }
400dab
 
400dab
         g_debug ("GdmLocalDisplayFactory: VT changed from %s to %s",
400dab
                  tty_of_previous_vt, factory->priv->tty_of_active_vt);
400dab
 
400dab
         /* if the old VT was running a wayland login screen kill it
400dab
          */
400dab
         if (gdm_get_login_window_session_id ("seat0", &login_session_id)) {
400dab
                 unsigned int vt;
400dab
 
400dab
                 ret = sd_session_get_vt (login_session_id, &vt;;
400dab
                 if (ret == 0 && vt != 0) {
400dab
                         g_autofree char *tty_of_login_window_vt = NULL;
400dab
 
400dab
                         tty_of_login_window_vt = g_strdup_printf ("tty%u", vt);
400dab
 
400dab
                         g_debug ("GdmLocalDisplayFactory: tty of login window is %s", tty_of_login_window_vt);
400dab
                         if (g_strcmp0 (tty_of_login_window_vt, tty_of_previous_vt) == 0) {
400dab
                                 GdmDisplayStore *store;
400dab
                                 GdmDisplay *display;
400dab
 
400dab
                                 g_debug ("GdmLocalDisplayFactory: VT switched from login window");
400dab
-- 
400dab
2.27.0
400dab