|
|
a1b388 |
From 59533722f1749d4e71360c5d717a18006c1f64c0 Mon Sep 17 00:00:00 2001
|
|
|
a1b388 |
From: Ray Strode <rstrode@redhat.com>
|
|
|
a1b388 |
Date: Tue, 7 Aug 2018 13:55:06 -0400
|
|
|
a1b388 |
Subject: [PATCH 15/51] local-display-factory: add more debug messages to new
|
|
|
a1b388 |
vt handling code
|
|
|
a1b388 |
|
|
|
a1b388 |
commit c0188a7030 added some complex code for starting and stopping
|
|
|
a1b388 |
the login screen based on VT changes.
|
|
|
a1b388 |
|
|
|
a1b388 |
That code currently has zero debug statements in it making it trickier
|
|
|
a1b388 |
than necessary to debug.
|
|
|
a1b388 |
|
|
|
a1b388 |
This commit sprinkles some g_debug's throughout the function.
|
|
|
a1b388 |
---
|
|
|
a1b388 |
daemon/gdm-local-display-factory.c | 44 ++++++++++++++++++++++++------
|
|
|
a1b388 |
1 file changed, 35 insertions(+), 9 deletions(-)
|
|
|
a1b388 |
|
|
|
a1b388 |
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
|
|
|
a1b388 |
index 4ae656ab3..2a2259f2a 100644
|
|
|
a1b388 |
--- a/daemon/gdm-local-display-factory.c
|
|
|
a1b388 |
+++ b/daemon/gdm-local-display-factory.c
|
|
|
a1b388 |
@@ -530,175 +530,201 @@ on_seat_removed (GDBusConnection *connection,
|
|
|
a1b388 |
const gchar *object_path,
|
|
|
a1b388 |
const gchar *interface_name,
|
|
|
a1b388 |
const gchar *signal_name,
|
|
|
a1b388 |
GVariant *parameters,
|
|
|
a1b388 |
gpointer user_data)
|
|
|
a1b388 |
{
|
|
|
a1b388 |
const char *seat;
|
|
|
a1b388 |
|
|
|
a1b388 |
g_variant_get (parameters, "(&s&o)", &seat, NULL);
|
|
|
a1b388 |
delete_display (GDM_LOCAL_DISPLAY_FACTORY (user_data), seat);
|
|
|
a1b388 |
}
|
|
|
a1b388 |
|
|
|
a1b388 |
#if defined(ENABLE_WAYLAND_SUPPORT) && defined(ENABLE_USER_DISPLAY_SERVER)
|
|
|
a1b388 |
static gboolean
|
|
|
a1b388 |
lookup_by_session_id (const char *id,
|
|
|
a1b388 |
GdmDisplay *display,
|
|
|
a1b388 |
gpointer user_data)
|
|
|
a1b388 |
{
|
|
|
a1b388 |
const char *looking_for = user_data;
|
|
|
a1b388 |
const char *current;
|
|
|
a1b388 |
|
|
|
a1b388 |
current = gdm_display_get_session_id (display);
|
|
|
a1b388 |
return g_strcmp0 (current, looking_for) == 0;
|
|
|
a1b388 |
}
|
|
|
a1b388 |
|
|
|
a1b388 |
static void
|
|
|
a1b388 |
maybe_stop_greeter_display (GdmDisplay *display)
|
|
|
a1b388 |
{
|
|
|
a1b388 |
g_autofree char *display_session_type = NULL;
|
|
|
a1b388 |
|
|
|
a1b388 |
- if (gdm_display_get_status (display) != GDM_DISPLAY_MANAGED)
|
|
|
a1b388 |
+ if (gdm_display_get_status (display) != GDM_DISPLAY_MANAGED) {
|
|
|
a1b388 |
+ g_debug ("GdmLocalDisplayFactory: login window not in managed state, so ignoring");
|
|
|
a1b388 |
return;
|
|
|
a1b388 |
+ }
|
|
|
a1b388 |
|
|
|
a1b388 |
g_object_get (G_OBJECT (display),
|
|
|
a1b388 |
"session-type", &display_session_type,
|
|
|
a1b388 |
NULL);
|
|
|
a1b388 |
|
|
|
a1b388 |
/* we can only stop greeter for wayland sessions, since
|
|
|
a1b388 |
* X server would jump back on exit */
|
|
|
a1b388 |
- if (g_strcmp0 (display_session_type, "wayland") != 0)
|
|
|
a1b388 |
+ if (g_strcmp0 (display_session_type, "wayland") != 0) {
|
|
|
a1b388 |
+ g_debug ("GdmLocalDisplayFactory: login window is running on Xorg, so ignoring");
|
|
|
a1b388 |
return;
|
|
|
a1b388 |
+ }
|
|
|
a1b388 |
|
|
|
a1b388 |
+ g_debug ("GdmLocalDisplayFactory: killing login window since its now unused");
|
|
|
a1b388 |
gdm_display_stop_greeter_session (display);
|
|
|
a1b388 |
gdm_display_unmanage (display);
|
|
|
a1b388 |
gdm_display_finish (display);
|
|
|
a1b388 |
}
|
|
|
a1b388 |
|
|
|
a1b388 |
static gboolean
|
|
|
a1b388 |
on_vt_changed (GIOChannel *source,
|
|
|
a1b388 |
GIOCondition condition,
|
|
|
a1b388 |
GdmLocalDisplayFactory *factory)
|
|
|
a1b388 |
{
|
|
|
a1b388 |
GIOStatus status;
|
|
|
a1b388 |
static const char *tty_of_initial_vt = "tty" GDM_INITIAL_VT;
|
|
|
a1b388 |
g_autofree char *tty_of_previous_vt = NULL;
|
|
|
a1b388 |
g_autofree char *tty_of_active_vt = NULL;
|
|
|
a1b388 |
g_autofree char *login_session_id = NULL;
|
|
|
a1b388 |
g_autofree char *active_session_id = NULL;
|
|
|
a1b388 |
const char *session_type = NULL;
|
|
|
a1b388 |
int ret;
|
|
|
a1b388 |
|
|
|
a1b388 |
+ g_debug ("GdmLocalDisplayFactory: received VT change event");
|
|
|
a1b388 |
g_io_channel_seek_position (source, 0, G_SEEK_SET, NULL);
|
|
|
a1b388 |
|
|
|
a1b388 |
if (condition & G_IO_PRI) {
|
|
|
a1b388 |
g_autoptr (GError) error = NULL;
|
|
|
a1b388 |
status = g_io_channel_read_line (source, &tty_of_active_vt, NULL, NULL, &error);
|
|
|
a1b388 |
|
|
|
a1b388 |
if (error != NULL) {
|
|
|
a1b388 |
g_warning ("could not read active VT from kernel: %s", error->message);
|
|
|
a1b388 |
}
|
|
|
a1b388 |
switch (status) {
|
|
|
a1b388 |
case G_IO_STATUS_ERROR:
|
|
|
a1b388 |
return G_SOURCE_REMOVE;
|
|
|
a1b388 |
case G_IO_STATUS_EOF:
|
|
|
a1b388 |
return G_SOURCE_REMOVE;
|
|
|
a1b388 |
case G_IO_STATUS_AGAIN:
|
|
|
a1b388 |
return G_SOURCE_CONTINUE;
|
|
|
a1b388 |
case G_IO_STATUS_NORMAL:
|
|
|
a1b388 |
break;
|
|
|
a1b388 |
}
|
|
|
a1b388 |
}
|
|
|
a1b388 |
|
|
|
a1b388 |
- if ((condition & G_IO_ERR) || (condition & G_IO_HUP))
|
|
|
a1b388 |
+ if ((condition & G_IO_ERR) || (condition & G_IO_HUP)) {
|
|
|
a1b388 |
+ g_debug ("GdmLocalDisplayFactory: kernel hung up active vt watch");
|
|
|
a1b388 |
return G_SOURCE_REMOVE;
|
|
|
a1b388 |
+ }
|
|
|
a1b388 |
|
|
|
a1b388 |
- if (tty_of_active_vt == NULL)
|
|
|
a1b388 |
+ if (tty_of_active_vt == NULL) {
|
|
|
a1b388 |
+ g_debug ("GdmLocalDisplayFactory: unable to read active VT from kernel");
|
|
|
a1b388 |
return G_SOURCE_CONTINUE;
|
|
|
a1b388 |
+ }
|
|
|
a1b388 |
|
|
|
a1b388 |
g_strchomp (tty_of_active_vt);
|
|
|
a1b388 |
|
|
|
a1b388 |
- /* don't do anything if we're on the same VT we were before */
|
|
|
a1b388 |
- if (g_strcmp0 (tty_of_active_vt, factory->priv->tty_of_active_vt) == 0)
|
|
|
a1b388 |
- return G_SOURCE_CONTINUE;
|
|
|
a1b388 |
-
|
|
|
a1b388 |
tty_of_previous_vt = g_steal_pointer (&factory->priv->tty_of_active_vt);
|
|
|
a1b388 |
factory->priv->tty_of_active_vt = g_steal_pointer (&tty_of_active_vt);
|
|
|
a1b388 |
|
|
|
a1b388 |
+ /* don't do anything at start up */
|
|
|
a1b388 |
+ if (tty_of_previous_vt == NULL) {
|
|
|
a1b388 |
+ g_debug ("GdmLocalDisplayFactory: VT is %s at startup",
|
|
|
a1b388 |
+ factory->priv->tty_of_active_vt);
|
|
|
a1b388 |
+ return G_SOURCE_CONTINUE;
|
|
|
a1b388 |
+ }
|
|
|
a1b388 |
+
|
|
|
a1b388 |
+ g_debug ("GdmLocalDisplayFactory: VT changed from %s to %s",
|
|
|
a1b388 |
+ tty_of_previous_vt, factory->priv->tty_of_active_vt);
|
|
|
a1b388 |
+
|
|
|
a1b388 |
/* if the old VT was running a wayland login screen kill it
|
|
|
a1b388 |
*/
|
|
|
a1b388 |
if (gdm_get_login_window_session_id ("seat0", &login_session_id)) {
|
|
|
a1b388 |
unsigned int vt;
|
|
|
a1b388 |
|
|
|
a1b388 |
ret = sd_session_get_vt (login_session_id, &vt;;
|
|
|
a1b388 |
if (ret == 0 && vt != 0) {
|
|
|
a1b388 |
g_autofree char *tty_of_login_window_vt = NULL;
|
|
|
a1b388 |
|
|
|
a1b388 |
tty_of_login_window_vt = g_strdup_printf ("tty%u", vt);
|
|
|
a1b388 |
|
|
|
a1b388 |
+ g_debug ("GdmLocalDisplayFactory: tty of login window is %s", tty_of_login_window_vt);
|
|
|
a1b388 |
if (g_strcmp0 (tty_of_login_window_vt, tty_of_previous_vt) == 0) {
|
|
|
a1b388 |
GdmDisplayStore *store;
|
|
|
a1b388 |
GdmDisplay *display;
|
|
|
a1b388 |
|
|
|
a1b388 |
+ g_debug ("GdmLocalDisplayFactory: VT switched from login window");
|
|
|
a1b388 |
+
|
|
|
a1b388 |
store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
|
|
|
a1b388 |
display = gdm_display_store_find (store,
|
|
|
a1b388 |
lookup_by_session_id,
|
|
|
a1b388 |
(gpointer) login_session_id);
|
|
|
a1b388 |
|
|
|
a1b388 |
if (display != NULL)
|
|
|
a1b388 |
maybe_stop_greeter_display (display);
|
|
|
a1b388 |
+ } else {
|
|
|
a1b388 |
+ g_debug ("GdmLocalDisplayFactory: VT not switched from login window");
|
|
|
a1b388 |
}
|
|
|
a1b388 |
}
|
|
|
a1b388 |
}
|
|
|
a1b388 |
|
|
|
a1b388 |
/* if user jumped back to initial vt and it's empty put a login screen
|
|
|
a1b388 |
* on it (unless a login screen is already running elsewhere, then
|
|
|
a1b388 |
* jump to that login screen)
|
|
|
a1b388 |
*/
|
|
|
a1b388 |
if (strcmp (factory->priv->tty_of_active_vt, tty_of_initial_vt) != 0) {
|
|
|
a1b388 |
+ g_debug ("GdmLocalDisplayFactory: active VT is not initial VT, so ignoring");
|
|
|
a1b388 |
return G_SOURCE_CONTINUE;
|
|
|
a1b388 |
}
|
|
|
a1b388 |
|
|
|
a1b388 |
ret = sd_seat_get_active ("seat0", &active_session_id, NULL);
|
|
|
a1b388 |
|
|
|
a1b388 |
if (ret == 0) {
|
|
|
a1b388 |
g_autofree char *state = NULL;
|
|
|
a1b388 |
ret = sd_session_get_state (active_session_id, &state);
|
|
|
a1b388 |
|
|
|
a1b388 |
/* if there's something already running on the active VT then bail */
|
|
|
a1b388 |
- if (ret == 0 && g_strcmp0 (state, "closing") != 0)
|
|
|
a1b388 |
+ if (ret == 0 && g_strcmp0 (state, "closing") != 0) {
|
|
|
a1b388 |
+ g_debug ("GdmLocalDisplayFactory: initial VT is in use, so ignoring");
|
|
|
a1b388 |
return G_SOURCE_CONTINUE;
|
|
|
a1b388 |
+ }
|
|
|
a1b388 |
}
|
|
|
a1b388 |
|
|
|
a1b388 |
if (gdm_local_display_factory_use_wayland ())
|
|
|
a1b388 |
session_type = "wayland";
|
|
|
a1b388 |
|
|
|
a1b388 |
+ g_debug ("GdmLocalDisplayFactory: creating new display on seat0 because of VT change");
|
|
|
a1b388 |
+
|
|
|
a1b388 |
create_display (factory, "seat0", session_type, TRUE);
|
|
|
a1b388 |
|
|
|
a1b388 |
return G_SOURCE_CONTINUE;
|
|
|
a1b388 |
}
|
|
|
a1b388 |
#endif
|
|
|
a1b388 |
|
|
|
a1b388 |
static void
|
|
|
a1b388 |
gdm_local_display_factory_start_monitor (GdmLocalDisplayFactory *factory)
|
|
|
a1b388 |
{
|
|
|
a1b388 |
g_autoptr (GIOChannel) io_channel = NULL;
|
|
|
a1b388 |
|
|
|
a1b388 |
factory->priv->seat_new_id = g_dbus_connection_signal_subscribe (factory->priv->connection,
|
|
|
a1b388 |
"org.freedesktop.login1",
|
|
|
a1b388 |
"org.freedesktop.login1.Manager",
|
|
|
a1b388 |
"SeatNew",
|
|
|
a1b388 |
"/org/freedesktop/login1",
|
|
|
a1b388 |
NULL,
|
|
|
a1b388 |
G_DBUS_SIGNAL_FLAGS_NONE,
|
|
|
a1b388 |
on_seat_new,
|
|
|
a1b388 |
g_object_ref (factory),
|
|
|
a1b388 |
g_object_unref);
|
|
|
a1b388 |
factory->priv->seat_removed_id = g_dbus_connection_signal_subscribe (factory->priv->connection,
|
|
|
a1b388 |
"org.freedesktop.login1",
|
|
|
a1b388 |
"org.freedesktop.login1.Manager",
|
|
|
a1b388 |
"SeatRemoved",
|
|
|
a1b388 |
"/org/freedesktop/login1",
|
|
|
a1b388 |
NULL,
|
|
|
a1b388 |
G_DBUS_SIGNAL_FLAGS_NONE,
|
|
|
a1b388 |
on_seat_removed,
|
|
|
a1b388 |
g_object_ref (factory),
|
|
|
a1b388 |
--
|
|
|
a1b388 |
2.27.0
|
|
|
a1b388 |
|