gdm/gdm-add-runtime-option-to-disable-starting-X-server-as-u.patch

146 lines
5.4 KiB
Diff

From a19b51ad9e446948ba60c359641f6c4c14fec1da Mon Sep 17 00:00:00 2001
From: Michal Srb <msrb@suse.com>
Date: Fri, 26 Jan 2018 10:49:18 +0100
Subject: [PATCH] Add runtime option to disable starting X server as user
If the environmental variable GDM_DISABLE_USER_DISPLAY_SERVER is defined, the
X server will be started under root. The same way as if gdm was built with
--disable-user-display-server option.
This allows system to run X server under root if and only-if necessary.
--- a/daemon/gdm-local-display-factory.c
+++ b/daemon/gdm-local-display-factory.c
@@ -384,6 +384,7 @@ gdm_local_display_factory_create_transie
preferred_display_server = get_preferred_display_server (factory);
#ifdef ENABLE_USER_DISPLAY_SERVER
+ if (getenv ("GDM_DISABLE_USER_DISPLAY_SERVER") == NULL ) {
if (g_strcmp0 (preferred_display_server, "wayland") == 0 ||
g_strcmp0 (preferred_display_server, "xorg") == 0) {
g_auto(GStrv) session_types = NULL;
@@ -405,8 +406,9 @@ gdm_local_display_factory_create_transie
NULL);
is_initial = TRUE;
}
+ }
#endif
- if (g_strcmp0 (preferred_display_server, "legacy-xorg") == 0) {
+ //if (g_strcmp0 (preferred_display_server, "legacy-xorg") == 0) {
if (display == NULL) {
guint32 num;
@@ -414,7 +416,7 @@ gdm_local_display_factory_create_transie
display = gdm_legacy_display_new (num);
}
- }
+ //}
if (display == NULL) {
g_set_error_literal (error,
@@ -905,6 +907,7 @@ ensure_display_for_seat (GdmLocalDisplay
g_debug ("GdmLocalDisplayFactory: Adding display on seat %s", seat_id);
#ifdef ENABLE_USER_DISPLAY_SERVER
+ if (getenv ("GDM_DISABLE_USER_DISPLAY_SERVER") == NULL ) {
if (g_strcmp0 (preferred_display_server, "wayland") == 0 ||
g_strcmp0 (preferred_display_server, "xorg") == 0) {
if (is_seat0) {
@@ -915,6 +918,7 @@ ensure_display_for_seat (GdmLocalDisplay
NULL);
}
}
+ }
#endif
if (display == NULL) {
@@ -1211,6 +1215,10 @@ on_vt_changed (GIOChannel *source,
g_debug ("GdmLocalDisplayFactory: VT changed from %u to %u",
previous_vt, factory->active_vt);
+ if (getenv ("GDM_DISABLE_USER_DISPLAY_SERVER") != NULL) {
+ return G_SOURCE_CONTINUE;
+ }
+
store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
/* if the old VT was running a wayland login screen kill it
@@ -1352,6 +1360,7 @@ gdm_local_display_factory_start_monitor
#endif
#if defined(ENABLE_USER_DISPLAY_SERVER)
+ if (getenv ("GDM_DISABLE_USER_DISPLAY_SERVER") == NULL ) {
io_channel = g_io_channel_new_file ("/sys/class/tty/tty0/active", "r", NULL);
if (io_channel != NULL) {
@@ -1362,6 +1371,7 @@ gdm_local_display_factory_start_monitor
on_vt_changed,
factory);
}
+ }
#endif
}
--- a/daemon/gdm-manager.c
+++ b/daemon/gdm-manager.c
@@ -1355,6 +1355,8 @@ set_up_automatic_login_session (GdmManag
"supported-session-types", supported_session_types,
NULL);
+ if (getenv ("GDM_DISABLE_USER_DISPLAY_SERVER") != NULL)
+ manager->priv->did_automatic_login = TRUE;
g_debug ("GdmManager: Starting automatic login conversation");
gdm_session_start_conversation (session, "gdm-autologin");
}
--- a/daemon/gdm-server.c
+++ b/daemon/gdm-server.c
@@ -238,9 +238,9 @@ gdm_server_init_command (GdmServer *serv
/* For systemd, we don't have a log file but instead log to stdout,
so set it to the xserver's built-in default verbosity */
if (debug)
- verbosity = "7 -logfile /dev/null";
+ verbosity = "7";
else
- verbosity = "3 -logfile /dev/null";
+ verbosity = "3";
#endif
if (g_access (SYSTEMD_X_SERVER, X_OK) < 0) {
@@ -755,7 +755,7 @@ gdm_server_start (GdmServer *server)
g_return_val_if_fail (GDM_IS_SERVER (server), FALSE);
/* Hardcode the VT for the initial X server, but nothing else */
- if (server->is_initial) {
+ if (server->is_initial && g_strcmp0 (server->display_name, ":0") == 0) {
vtarg = "vt" G_STRINGIFY (GDM_INITIAL_VT);
}
--- a/daemon/gdm-session.c
+++ b/daemon/gdm-session.c
@@ -3371,6 +3371,7 @@ gdm_session_get_display_mode (GdmSession
}
#ifdef ENABLE_USER_DISPLAY_SERVER
+ if (getenv ("GDM_DISABLE_USER_DISPLAY_SERVER") == NULL ) {
/* All other cases (wayland login screen, X login screen,
* wayland user session, X user session) use the NEW_VT
* display mode. That display mode means that GDM allocates
@@ -3393,7 +3394,8 @@ gdm_session_get_display_mode (GdmSession
* are paused when handed out.
*/
return GDM_SESSION_DISPLAY_MODE_NEW_VT;
-#else
+//#else
+ } else {
#ifdef ENABLE_WAYLAND_SUPPORT
/* Wayland sessions are for now assumed to run in a
@@ -3404,6 +3406,7 @@ gdm_session_get_display_mode (GdmSession
}
#endif
return GDM_SESSION_DISPLAY_MODE_REUSE_VT;
+ }
#endif
}