Blob Blame History Raw
From e5bf6d78ff8f54bbb74e572f05ccbf1c0df24017 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Tue, 7 Aug 2018 13:55:06 -0400
Subject: [PATCH 16/51] local-display-factory: don't start two greeters at
 startup

commit c0188a7030 added some complex code for starting
the login screen when the user switches to the initial
VT if nothing is running on that VT.

The problem is, we get a VT change event on that VT as
part of the start up process.

This leads to an additional greeter getting started.

This commit adds a check to side step the new code during
startup.

Closes: https://gitlab.gnome.org/GNOME/gdm/issues/409
---
 daemon/gdm-local-display-factory.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
index 2a2259f2a..9f377ba9a 100644
--- a/daemon/gdm-local-display-factory.c
+++ b/daemon/gdm-local-display-factory.c
@@ -600,60 +600,66 @@ on_vt_changed (GIOChannel    *source,
                 g_autoptr (GError) error = NULL;
                 status = g_io_channel_read_line (source, &tty_of_active_vt, NULL, NULL, &error);
 
                 if (error != NULL) {
                         g_warning ("could not read active VT from kernel: %s", error->message);
                 }
                 switch (status) {
                         case G_IO_STATUS_ERROR:
                             return G_SOURCE_REMOVE;
                         case G_IO_STATUS_EOF:
                             return G_SOURCE_REMOVE;
                         case G_IO_STATUS_AGAIN:
                             return G_SOURCE_CONTINUE;
                         case G_IO_STATUS_NORMAL:
                             break;
                 }
         }
 
         if ((condition & G_IO_ERR) || (condition & G_IO_HUP)) {
                 g_debug ("GdmLocalDisplayFactory: kernel hung up active vt watch");
                 return G_SOURCE_REMOVE;
         }
 
         if (tty_of_active_vt == NULL) {
                 g_debug ("GdmLocalDisplayFactory: unable to read active VT from kernel");
                 return G_SOURCE_CONTINUE;
         }
 
         g_strchomp (tty_of_active_vt);
 
+        /* don't do anything if we're on the same VT we were before */
+        if (g_strcmp0 (tty_of_active_vt, factory->priv->tty_of_active_vt) == 0) {
+                g_debug ("GdmLocalDisplayFactory: VT changed to the same VT, ignoring");
+                return G_SOURCE_CONTINUE;
+        }
+
         tty_of_previous_vt = g_steal_pointer (&factory->priv->tty_of_active_vt);
         factory->priv->tty_of_active_vt = g_steal_pointer (&tty_of_active_vt);
 
         /* don't do anything at start up */
         if (tty_of_previous_vt == NULL) {
                 g_debug ("GdmLocalDisplayFactory: VT is %s at startup",
                          factory->priv->tty_of_active_vt);
                 return G_SOURCE_CONTINUE;
         }
 
         g_debug ("GdmLocalDisplayFactory: VT changed from %s to %s",
                  tty_of_previous_vt, factory->priv->tty_of_active_vt);
 
         /* if the old VT was running a wayland login screen kill it
          */
         if (gdm_get_login_window_session_id ("seat0", &login_session_id)) {
                 unsigned int vt;
 
                 ret = sd_session_get_vt (login_session_id, &vt);
                 if (ret == 0 && vt != 0) {
                         g_autofree char *tty_of_login_window_vt = NULL;
 
                         tty_of_login_window_vt = g_strdup_printf ("tty%u", vt);
 
                         g_debug ("GdmLocalDisplayFactory: tty of login window is %s", tty_of_login_window_vt);
                         if (g_strcmp0 (tty_of_login_window_vt, tty_of_previous_vt) == 0) {
                                 GdmDisplayStore *store;
                                 GdmDisplay *display;
 
                                 g_debug ("GdmLocalDisplayFactory: VT switched from login window");
-- 
2.27.0