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

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