|
|
e0b6b0 |
From 3cf5b4b12d3d39fa858ff593adeecfe711cdddaf Mon Sep 17 00:00:00 2001
|
|
|
c90517 |
From: Iain Lane <iainl@gnome.org>
|
|
|
c90517 |
Date: Tue, 7 May 2019 15:35:23 +0100
|
|
|
e0b6b0 |
Subject: [PATCH 42/51] GdmLocalDisplayFactory: Store VT number, not tty
|
|
|
c90517 |
identifier
|
|
|
c90517 |
|
|
|
c90517 |
This makes the code a fair bit simpler.
|
|
|
c90517 |
---
|
|
|
c90517 |
configure.ac | 6 ++--
|
|
|
c90517 |
daemon/gdm-local-display-factory.c | 50 ++++++++++++++++--------------
|
|
|
c90517 |
daemon/gdm-server.c | 2 +-
|
|
|
c90517 |
daemon/gdm-session-worker.c | 2 +-
|
|
|
c90517 |
4 files changed, 31 insertions(+), 29 deletions(-)
|
|
|
c90517 |
|
|
|
c90517 |
diff --git a/configure.ac b/configure.ac
|
|
|
c90517 |
index c549146ce..0c138ab38 100644
|
|
|
c90517 |
--- a/configure.ac
|
|
|
c90517 |
+++ b/configure.ac
|
|
|
c90517 |
@@ -1477,66 +1477,66 @@ fi
|
|
|
c90517 |
AC_SUBST(DEBUG_CFLAGS)
|
|
|
c90517 |
|
|
|
c90517 |
#
|
|
|
c90517 |
# Enable Profiling
|
|
|
c90517 |
#
|
|
|
c90517 |
AC_ARG_ENABLE(profiling,
|
|
|
c90517 |
AS_HELP_STRING([--enable-profiling],
|
|
|
c90517 |
[turn on profiling]),,
|
|
|
c90517 |
enable_profiling=yes)
|
|
|
c90517 |
|
|
|
c90517 |
if test "$enable_profiling" = "yes"; then
|
|
|
c90517 |
AC_DEFINE(ENABLE_PROFILING,1,[enable profiling])
|
|
|
c90517 |
fi
|
|
|
c90517 |
|
|
|
c90517 |
#
|
|
|
c90517 |
# Set SHELL to use in scripts.
|
|
|
c90517 |
#
|
|
|
c90517 |
if test x$os_solaris = xyes ; then
|
|
|
c90517 |
XSESSION_SHELL=/bin/ksh
|
|
|
c90517 |
else
|
|
|
c90517 |
XSESSION_SHELL=/bin/sh
|
|
|
c90517 |
fi
|
|
|
c90517 |
|
|
|
c90517 |
#
|
|
|
c90517 |
# Set VT to use for initial server
|
|
|
c90517 |
#
|
|
|
c90517 |
AC_ARG_WITH(initial-vt,
|
|
|
c90517 |
AS_HELP_STRING([--with-initial-vt=<nr>],
|
|
|
c90517 |
[Initial virtual terminal to use]))
|
|
|
c90517 |
if ! test -z "$with_initial_vt"; then
|
|
|
c90517 |
- GDM_INITIAL_VT="$with_initial_vt"
|
|
|
c90517 |
+ GDM_INITIAL_VT=$with_initial_vt
|
|
|
c90517 |
else
|
|
|
c90517 |
- GDM_INITIAL_VT="1"
|
|
|
c90517 |
+ GDM_INITIAL_VT=1
|
|
|
c90517 |
fi
|
|
|
c90517 |
AC_SUBST(GDM_INITIAL_VT)
|
|
|
c90517 |
-AC_DEFINE_UNQUOTED(GDM_INITIAL_VT, "$GDM_INITIAL_VT", [Initial Virtual Terminal])
|
|
|
c90517 |
+AC_DEFINE_UNQUOTED(GDM_INITIAL_VT, $GDM_INITIAL_VT, [Initial Virtual Terminal])
|
|
|
c90517 |
|
|
|
c90517 |
# Set configuration choices.
|
|
|
c90517 |
#
|
|
|
c90517 |
AC_SUBST(XSESSION_SHELL)
|
|
|
c90517 |
AC_DEFINE_UNQUOTED(XSESSION_SHELL,"$XSESSION_SHELL",[xsession shell])
|
|
|
c90517 |
AC_SUBST(SOUND_PROGRAM)
|
|
|
c90517 |
AC_DEFINE_UNQUOTED(SOUND_PROGRAM,"$SOUND_PROGRAM",[])
|
|
|
c90517 |
|
|
|
c90517 |
AC_SUBST(X_PATH)
|
|
|
c90517 |
AC_SUBST(X_SERVER)
|
|
|
c90517 |
AC_SUBST(X_SERVER_PATH)
|
|
|
c90517 |
AC_DEFINE_UNQUOTED(X_SERVER,"$X_SERVER",[])
|
|
|
c90517 |
AC_DEFINE_UNQUOTED(X_SERVER_PATH,"$X_SERVER_PATH",[])
|
|
|
c90517 |
|
|
|
c90517 |
## Stuff for debian/changelog.in
|
|
|
c90517 |
#if test -e "debian/changelog"; then
|
|
|
c90517 |
# DEBIAN_DATESTAMP=`head -1 debian/changelog| sed -e 's/.*cvs.//' -e 's/).*//'`
|
|
|
c90517 |
# DEBIAN_DATE=`grep '^ --' debian/changelog | head -1 | sed -e 's/.* //'`
|
|
|
c90517 |
#else
|
|
|
c90517 |
# DEBIAN_DATESTAMP=`date +%Y%m%d%H%M%s`
|
|
|
c90517 |
# DEBIAN_DATE=`date -R`
|
|
|
c90517 |
#fi
|
|
|
c90517 |
#
|
|
|
c90517 |
#AC_SUBST(DEBIAN_DATESTAMP)
|
|
|
c90517 |
#AC_SUBST(DEBIAN_DATE)
|
|
|
c90517 |
|
|
|
c90517 |
AC_CONFIG_FILES([
|
|
|
c90517 |
Makefile
|
|
|
c90517 |
pam-extensions/Makefile
|
|
|
c90517 |
pam-extensions/gdm-pam-extensions.pc
|
|
|
c90517 |
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
|
|
|
c90517 |
index d999596b5..7a013c694 100644
|
|
|
c90517 |
--- a/daemon/gdm-local-display-factory.c
|
|
|
c90517 |
+++ b/daemon/gdm-local-display-factory.c
|
|
|
c90517 |
@@ -37,61 +37,61 @@
|
|
|
c90517 |
#include "gdm-local-display-factory-glue.h"
|
|
|
c90517 |
|
|
|
c90517 |
#include "gdm-settings-keys.h"
|
|
|
c90517 |
#include "gdm-settings-direct.h"
|
|
|
c90517 |
#include "gdm-display-store.h"
|
|
|
c90517 |
#include "gdm-local-display.h"
|
|
|
c90517 |
#include "gdm-legacy-display.h"
|
|
|
c90517 |
|
|
|
c90517 |
#define GDM_LOCAL_DISPLAY_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_LOCAL_DISPLAY_FACTORY, GdmLocalDisplayFactoryPrivate))
|
|
|
c90517 |
|
|
|
c90517 |
#define GDM_DBUS_PATH "/org/gnome/DisplayManager"
|
|
|
c90517 |
#define GDM_LOCAL_DISPLAY_FACTORY_DBUS_PATH GDM_DBUS_PATH "/LocalDisplayFactory"
|
|
|
c90517 |
#define GDM_MANAGER_DBUS_NAME "org.gnome.DisplayManager.LocalDisplayFactory"
|
|
|
c90517 |
|
|
|
c90517 |
#define MAX_DISPLAY_FAILURES 5
|
|
|
c90517 |
#define WAIT_TO_FINISH_TIMEOUT 10 /* seconds */
|
|
|
c90517 |
|
|
|
c90517 |
struct GdmLocalDisplayFactoryPrivate
|
|
|
c90517 |
{
|
|
|
c90517 |
GdmDBusLocalDisplayFactory *skeleton;
|
|
|
c90517 |
GDBusConnection *connection;
|
|
|
c90517 |
GHashTable *used_display_numbers;
|
|
|
c90517 |
|
|
|
c90517 |
/* FIXME: this needs to be per seat? */
|
|
|
c90517 |
guint num_failures;
|
|
|
c90517 |
|
|
|
c90517 |
guint seat_new_id;
|
|
|
c90517 |
guint seat_removed_id;
|
|
|
c90517 |
|
|
|
c90517 |
#if defined(ENABLE_WAYLAND_SUPPORT) && defined(ENABLE_USER_DISPLAY_SERVER)
|
|
|
c90517 |
- char *tty_of_active_vt;
|
|
|
c90517 |
+ unsigned int active_vt;
|
|
|
c90517 |
guint active_vt_watch_id;
|
|
|
c90517 |
guint wait_to_finish_timeout_id;
|
|
|
c90517 |
#endif
|
|
|
c90517 |
};
|
|
|
c90517 |
|
|
|
c90517 |
enum {
|
|
|
c90517 |
PROP_0,
|
|
|
c90517 |
};
|
|
|
c90517 |
|
|
|
c90517 |
static void gdm_local_display_factory_class_init (GdmLocalDisplayFactoryClass *klass);
|
|
|
c90517 |
static void gdm_local_display_factory_init (GdmLocalDisplayFactory *factory);
|
|
|
c90517 |
static void gdm_local_display_factory_finalize (GObject *object);
|
|
|
c90517 |
|
|
|
c90517 |
static GdmDisplay *create_display (GdmLocalDisplayFactory *factory,
|
|
|
c90517 |
const char *seat_id,
|
|
|
c90517 |
const char *session_type,
|
|
|
c90517 |
gboolean initial_display);
|
|
|
c90517 |
|
|
|
c90517 |
static void on_display_status_changed (GdmDisplay *display,
|
|
|
c90517 |
GParamSpec *arg1,
|
|
|
c90517 |
GdmLocalDisplayFactory *factory);
|
|
|
c90517 |
|
|
|
c90517 |
static gboolean gdm_local_display_factory_sync_seats (GdmLocalDisplayFactory *factory);
|
|
|
c90517 |
static gpointer local_display_factory_object = NULL;
|
|
|
c90517 |
static gboolean lookup_by_session_id (const char *id,
|
|
|
c90517 |
GdmDisplay *display,
|
|
|
c90517 |
gpointer user_data);
|
|
|
c90517 |
|
|
|
c90517 |
G_DEFINE_TYPE (GdmLocalDisplayFactory, gdm_local_display_factory, GDM_TYPE_DISPLAY_FACTORY)
|
|
|
c90517 |
|
|
|
c90517 |
@@ -641,157 +641,161 @@ maybe_stop_greeter_in_background (GdmLocalDisplayFactory *factory,
|
|
|
c90517 |
g_debug ("GdmLocalDisplayFactory: login window is performing initial-setup, so ignoring");
|
|
|
c90517 |
return;
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
/* we can only stop greeter for wayland sessions, since
|
|
|
c90517 |
* X server would jump back on exit */
|
|
|
c90517 |
if (g_strcmp0 (display_session_type, "wayland") != 0) {
|
|
|
c90517 |
g_debug ("GdmLocalDisplayFactory: login window is running on Xorg, so ignoring");
|
|
|
c90517 |
return;
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
g_debug ("GdmLocalDisplayFactory: killing login window once its unused");
|
|
|
c90517 |
g_object_set (G_OBJECT (display), "status", GDM_DISPLAY_WAITING_TO_FINISH, NULL);
|
|
|
c90517 |
|
|
|
c90517 |
/* We stop the greeter after a timeout to avoid flicker */
|
|
|
c90517 |
if (factory->priv->wait_to_finish_timeout_id != 0)
|
|
|
c90517 |
g_source_remove (factory->priv->wait_to_finish_timeout_id);
|
|
|
c90517 |
|
|
|
c90517 |
factory->priv->wait_to_finish_timeout_id =
|
|
|
c90517 |
g_timeout_add_seconds (WAIT_TO_FINISH_TIMEOUT,
|
|
|
c90517 |
(GSourceFunc)wait_to_finish_timeout,
|
|
|
c90517 |
factory);
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
static gboolean
|
|
|
c90517 |
on_vt_changed (GIOChannel *source,
|
|
|
c90517 |
GIOCondition condition,
|
|
|
c90517 |
GdmLocalDisplayFactory *factory)
|
|
|
c90517 |
{
|
|
|
c90517 |
GIOStatus status;
|
|
|
c90517 |
- static const char *tty_of_initial_vt = "tty" GDM_INITIAL_VT;
|
|
|
c90517 |
- g_autofree char *tty_of_previous_vt = NULL;
|
|
|
c90517 |
g_autofree char *tty_of_active_vt = NULL;
|
|
|
c90517 |
g_autofree char *login_session_id = NULL;
|
|
|
c90517 |
g_autofree char *active_session_id = NULL;
|
|
|
c90517 |
+ unsigned int previous_vt, new_vt;
|
|
|
c90517 |
const char *session_type = NULL;
|
|
|
c90517 |
- int ret;
|
|
|
c90517 |
+ int ret, n_returned;
|
|
|
c90517 |
|
|
|
c90517 |
g_debug ("GdmLocalDisplayFactory: received VT change event");
|
|
|
c90517 |
g_io_channel_seek_position (source, 0, G_SEEK_SET, NULL);
|
|
|
c90517 |
|
|
|
c90517 |
if (condition & G_IO_PRI) {
|
|
|
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 |
+ errno = 0;
|
|
|
c90517 |
+ n_returned = sscanf (tty_of_active_vt, "tty%u", &new_vt);
|
|
|
c90517 |
+
|
|
|
c90517 |
+ if (n_returned != 1 || errno != 0) {
|
|
|
c90517 |
+ g_critical ("GdmLocalDisplayFactory: Couldn't read active VT (got '%s')",
|
|
|
c90517 |
+ tty_of_active_vt);
|
|
|
c90517 |
+ return G_SOURCE_CONTINUE;
|
|
|
c90517 |
+ }
|
|
|
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 |
+ if (new_vt == factory->priv->active_vt) {
|
|
|
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 |
+ previous_vt = factory->priv->active_vt;
|
|
|
c90517 |
+ factory->priv->active_vt = new_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 |
+ if (previous_vt == 0) {
|
|
|
c90517 |
+ g_debug ("GdmLocalDisplayFactory: VT is %u at startup",
|
|
|
c90517 |
+ factory->priv->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 |
+ g_debug ("GdmLocalDisplayFactory: VT changed from %u to %u",
|
|
|
c90517 |
+ previous_vt, factory->priv->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 |
+ unsigned int login_window_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 |
+ ret = sd_session_get_vt (login_session_id, &login_window_vt);
|
|
|
c90517 |
+ if (ret == 0 && login_window_vt != 0) {
|
|
|
c90517 |
+ g_debug ("GdmLocalDisplayFactory: VT of login window is %u", login_window_vt);
|
|
|
c90517 |
+ if (login_window_vt == previous_vt) {
|
|
|
c90517 |
GdmDisplayStore *store;
|
|
|
c90517 |
GdmDisplay *display;
|
|
|
c90517 |
|
|
|
c90517 |
g_debug ("GdmLocalDisplayFactory: VT switched from login window");
|
|
|
c90517 |
|
|
|
c90517 |
store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
|
|
|
c90517 |
display = gdm_display_store_find (store,
|
|
|
c90517 |
lookup_by_session_id,
|
|
|
c90517 |
(gpointer) login_session_id);
|
|
|
c90517 |
|
|
|
c90517 |
if (display != NULL)
|
|
|
c90517 |
maybe_stop_greeter_in_background (factory, display);
|
|
|
c90517 |
} else {
|
|
|
c90517 |
g_debug ("GdmLocalDisplayFactory: VT not switched from login window");
|
|
|
c90517 |
}
|
|
|
c90517 |
}
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
/* if user jumped back to initial vt and it's empty put a login screen
|
|
|
c90517 |
* on it (unless a login screen is already running elsewhere, then
|
|
|
c90517 |
* jump to that login screen)
|
|
|
c90517 |
*/
|
|
|
c90517 |
- if (strcmp (factory->priv->tty_of_active_vt, tty_of_initial_vt) != 0) {
|
|
|
c90517 |
+ if (factory->priv->active_vt != GDM_INITIAL_VT) {
|
|
|
c90517 |
g_debug ("GdmLocalDisplayFactory: active VT is not initial VT, so ignoring");
|
|
|
c90517 |
return G_SOURCE_CONTINUE;
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
if (gdm_local_display_factory_use_wayland ())
|
|
|
c90517 |
session_type = "wayland";
|
|
|
c90517 |
|
|
|
c90517 |
g_debug ("GdmLocalDisplayFactory: creating new display on seat0 because of VT change");
|
|
|
c90517 |
|
|
|
c90517 |
create_display (factory, "seat0", session_type, TRUE);
|
|
|
c90517 |
|
|
|
c90517 |
return G_SOURCE_CONTINUE;
|
|
|
c90517 |
}
|
|
|
c90517 |
#endif
|
|
|
c90517 |
|
|
|
c90517 |
static void
|
|
|
c90517 |
gdm_local_display_factory_start_monitor (GdmLocalDisplayFactory *factory)
|
|
|
c90517 |
{
|
|
|
c90517 |
g_autoptr (GIOChannel) io_channel = NULL;
|
|
|
c90517 |
|
|
|
c90517 |
factory->priv->seat_new_id = g_dbus_connection_signal_subscribe (factory->priv->connection,
|
|
|
c90517 |
"org.freedesktop.login1",
|
|
|
c90517 |
"org.freedesktop.login1.Manager",
|
|
|
c90517 |
"SeatNew",
|
|
|
c90517 |
"/org/freedesktop/login1",
|
|
|
c90517 |
NULL,
|
|
|
c90517 |
G_DBUS_SIGNAL_FLAGS_NONE,
|
|
|
c90517 |
on_seat_new,
|
|
|
c90517 |
g_object_ref (factory),
|
|
|
c90517 |
g_object_unref);
|
|
|
c90517 |
@@ -815,62 +819,60 @@ gdm_local_display_factory_start_monitor (GdmLocalDisplayFactory *factory)
|
|
|
c90517 |
G_IO_PRI,
|
|
|
c90517 |
(GIOFunc)
|
|
|
c90517 |
on_vt_changed,
|
|
|
c90517 |
factory);
|
|
|
c90517 |
}
|
|
|
c90517 |
#endif
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
static void
|
|
|
c90517 |
gdm_local_display_factory_stop_monitor (GdmLocalDisplayFactory *factory)
|
|
|
c90517 |
{
|
|
|
c90517 |
if (factory->priv->seat_new_id) {
|
|
|
c90517 |
g_dbus_connection_signal_unsubscribe (factory->priv->connection,
|
|
|
c90517 |
factory->priv->seat_new_id);
|
|
|
c90517 |
factory->priv->seat_new_id = 0;
|
|
|
c90517 |
}
|
|
|
c90517 |
if (factory->priv->seat_removed_id) {
|
|
|
c90517 |
g_dbus_connection_signal_unsubscribe (factory->priv->connection,
|
|
|
c90517 |
factory->priv->seat_removed_id);
|
|
|
c90517 |
factory->priv->seat_removed_id = 0;
|
|
|
c90517 |
}
|
|
|
c90517 |
#if defined(ENABLE_WAYLAND_SUPPORT) && defined(ENABLE_USER_DISPLAY_SERVER)
|
|
|
c90517 |
if (factory->priv->wait_to_finish_timeout_id != 0) {
|
|
|
c90517 |
g_source_remove (factory->priv->wait_to_finish_timeout_id);
|
|
|
c90517 |
factory->priv->wait_to_finish_timeout_id = 0;
|
|
|
c90517 |
}
|
|
|
c90517 |
if (factory->priv->active_vt_watch_id) {
|
|
|
c90517 |
g_source_remove (factory->priv->active_vt_watch_id);
|
|
|
c90517 |
factory->priv->active_vt_watch_id = 0;
|
|
|
c90517 |
}
|
|
|
c90517 |
-
|
|
|
c90517 |
- g_clear_pointer (&factory->priv->tty_of_active_vt, g_free);
|
|
|
c90517 |
#endif
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
static void
|
|
|
c90517 |
on_display_added (GdmDisplayStore *display_store,
|
|
|
c90517 |
const char *id,
|
|
|
c90517 |
GdmLocalDisplayFactory *factory)
|
|
|
c90517 |
{
|
|
|
c90517 |
GdmDisplay *display;
|
|
|
c90517 |
|
|
|
c90517 |
display = gdm_display_store_lookup (display_store, id);
|
|
|
c90517 |
|
|
|
c90517 |
if (display != NULL) {
|
|
|
c90517 |
g_signal_connect_object (display, "notify::status",
|
|
|
c90517 |
G_CALLBACK (on_display_status_changed),
|
|
|
c90517 |
factory,
|
|
|
c90517 |
0);
|
|
|
c90517 |
|
|
|
c90517 |
g_object_weak_ref (G_OBJECT (display), (GWeakNotify)on_display_disposed, factory);
|
|
|
c90517 |
}
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
static void
|
|
|
c90517 |
on_display_removed (GdmDisplayStore *display_store,
|
|
|
c90517 |
GdmDisplay *display,
|
|
|
c90517 |
GdmLocalDisplayFactory *factory)
|
|
|
c90517 |
{
|
|
|
c90517 |
g_signal_handlers_disconnect_by_func (display, G_CALLBACK (on_display_status_changed), factory);
|
|
|
c90517 |
g_object_weak_unref (G_OBJECT (display), (GWeakNotify)on_display_disposed, factory);
|
|
|
c90517 |
}
|
|
|
c90517 |
diff --git a/daemon/gdm-server.c b/daemon/gdm-server.c
|
|
|
c90517 |
index 83fba99c8..04406a61a 100644
|
|
|
c90517 |
--- a/daemon/gdm-server.c
|
|
|
c90517 |
+++ b/daemon/gdm-server.c
|
|
|
c90517 |
@@ -726,61 +726,61 @@ gdm_server_spawn (GdmServer *server,
|
|
|
c90517 |
(GChildWatchFunc)server_child_watch,
|
|
|
c90517 |
server);
|
|
|
c90517 |
|
|
|
c90517 |
ret = TRUE;
|
|
|
c90517 |
out:
|
|
|
c90517 |
g_strfreev (argv);
|
|
|
c90517 |
if (env) {
|
|
|
c90517 |
g_ptr_array_foreach (env, (GFunc)g_free, NULL);
|
|
|
c90517 |
g_ptr_array_free (env, TRUE);
|
|
|
c90517 |
}
|
|
|
c90517 |
return ret;
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
/**
|
|
|
c90517 |
* gdm_server_start:
|
|
|
c90517 |
* @disp: Pointer to a GdmDisplay structure
|
|
|
c90517 |
*
|
|
|
c90517 |
* Starts a local X server. Handles retries and fatal errors properly.
|
|
|
c90517 |
*/
|
|
|
c90517 |
|
|
|
c90517 |
gboolean
|
|
|
c90517 |
gdm_server_start (GdmServer *server)
|
|
|
c90517 |
{
|
|
|
c90517 |
gboolean res = FALSE;
|
|
|
c90517 |
const char *vtarg = NULL;
|
|
|
c90517 |
GError *local_error = NULL;
|
|
|
c90517 |
GError **error = &local_error;
|
|
|
c90517 |
|
|
|
c90517 |
/* Hardcode the VT for the initial X server, but nothing else */
|
|
|
c90517 |
if (server->priv->is_initial) {
|
|
|
c90517 |
- vtarg = "vt" GDM_INITIAL_VT;
|
|
|
c90517 |
+ vtarg = "vt" G_STRINGIFY (GDM_INITIAL_VT);
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
/* fork X server process */
|
|
|
c90517 |
if (!gdm_server_spawn (server, vtarg, error)) {
|
|
|
c90517 |
goto out;
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
res = TRUE;
|
|
|
c90517 |
out:
|
|
|
c90517 |
if (local_error) {
|
|
|
c90517 |
g_printerr ("%s\n", local_error->message);
|
|
|
c90517 |
g_clear_error (&local_error);
|
|
|
c90517 |
}
|
|
|
c90517 |
return res;
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
static void
|
|
|
c90517 |
server_died (GdmServer *server)
|
|
|
c90517 |
{
|
|
|
c90517 |
int exit_status;
|
|
|
c90517 |
|
|
|
c90517 |
g_debug ("GdmServer: Waiting on process %d", server->priv->pid);
|
|
|
c90517 |
exit_status = gdm_wait_on_pid (server->priv->pid);
|
|
|
c90517 |
|
|
|
c90517 |
if (WIFEXITED (exit_status) && (WEXITSTATUS (exit_status) != 0)) {
|
|
|
c90517 |
g_debug ("GdmServer: Wait on child process failed");
|
|
|
c90517 |
} else {
|
|
|
c90517 |
/* exited normally */
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
|
|
|
c90517 |
index 7ed2789da..b4befaa83 100644
|
|
|
c90517 |
--- a/daemon/gdm-session-worker.c
|
|
|
c90517 |
+++ b/daemon/gdm-session-worker.c
|
|
|
c90517 |
@@ -2202,61 +2202,61 @@ gdm_session_worker_start_session (GdmSessionWorker *worker,
|
|
|
c90517 |
|
|
|
c90517 |
g_debug ("GdmSessionWorker: state SESSION_STARTED");
|
|
|
c90517 |
gdm_session_worker_set_state (worker, GDM_SESSION_WORKER_STATE_SESSION_STARTED);
|
|
|
c90517 |
|
|
|
c90517 |
gdm_session_worker_watch_child (worker);
|
|
|
c90517 |
|
|
|
c90517 |
out:
|
|
|
c90517 |
if (error_code != PAM_SUCCESS) {
|
|
|
c90517 |
gdm_session_worker_uninitialize_pam (worker, error_code);
|
|
|
c90517 |
return FALSE;
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
return TRUE;
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
static gboolean
|
|
|
c90517 |
set_up_for_new_vt (GdmSessionWorker *worker)
|
|
|
c90517 |
{
|
|
|
c90517 |
int fd;
|
|
|
c90517 |
char vt_string[256], tty_string[256];
|
|
|
c90517 |
int session_vt = 0;
|
|
|
c90517 |
|
|
|
c90517 |
fd = open ("/dev/tty0", O_RDWR | O_NOCTTY);
|
|
|
c90517 |
|
|
|
c90517 |
if (fd < 0) {
|
|
|
c90517 |
g_debug ("GdmSessionWorker: couldn't open VT master: %m");
|
|
|
c90517 |
return FALSE;
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
if (worker->priv->display_is_initial) {
|
|
|
c90517 |
- session_vt = atoi (GDM_INITIAL_VT);
|
|
|
c90517 |
+ session_vt = GDM_INITIAL_VT;
|
|
|
c90517 |
} else {
|
|
|
c90517 |
if (ioctl(fd, VT_OPENQRY, &session_vt) < 0) {
|
|
|
c90517 |
g_debug ("GdmSessionWorker: couldn't open new VT: %m");
|
|
|
c90517 |
goto fail;
|
|
|
c90517 |
}
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
worker->priv->session_vt = session_vt;
|
|
|
c90517 |
|
|
|
c90517 |
close (fd);
|
|
|
c90517 |
fd = -1;
|
|
|
c90517 |
|
|
|
c90517 |
g_assert (session_vt > 0);
|
|
|
c90517 |
|
|
|
c90517 |
g_snprintf (vt_string, sizeof (vt_string), "%d", session_vt);
|
|
|
c90517 |
|
|
|
c90517 |
/* Set the VTNR. This is used by logind to configure a session in
|
|
|
c90517 |
* the logind-managed case, but it doesn't hurt to set it always.
|
|
|
c90517 |
* When logind gains support for XDG_VTNR=auto, we can make the
|
|
|
c90517 |
* OPENQRY and this whole path only used by the new VT code. */
|
|
|
c90517 |
gdm_session_worker_set_environment_variable (worker,
|
|
|
c90517 |
"XDG_VTNR",
|
|
|
c90517 |
vt_string);
|
|
|
c90517 |
|
|
|
c90517 |
g_snprintf (tty_string, 256, "/dev/tty%d", session_vt);
|
|
|
c90517 |
worker->priv->session_tty_fd = open (tty_string, O_RDWR | O_NOCTTY);
|
|
|
c90517 |
pam_set_item (worker->priv->pam_handle, PAM_TTY, tty_string);
|
|
|
c90517 |
|
|
|
c90517 |
return TRUE;
|
|
|
c90517 |
|
|
|
c90517 |
--
|
|
|
e0b6b0 |
2.27.0
|
|
|
c90517 |
|