[gdm/wip/xserver-in-session: 19/19] slave: don't connect to X server
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm/wip/xserver-in-session: 19/19] slave: don't connect to X server
- Date: Thu, 29 Jan 2015 19:34:04 +0000 (UTC)
commit 9bde456f24276ae9cc41eeac9e8cff9fb483d3db
Author: Ray Strode <rstrode redhat com>
Date: Mon Jan 26 16:09:57 2015 -0500
slave: don't connect to X server
This commit prevents the main GDM process from connecting to the
X server directly.
daemon/gdm-simple-slave.c | 61 +++-------------------
daemon/gdm-slave.c | 107 --------------------------------------
daemon/gdm-slave.h | 2 -
daemon/gdm-xdmcp-chooser-slave.c | 52 +------------------
4 files changed, 9 insertions(+), 213 deletions(-)
---
diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c
index 0daf434..7597cf6 100644
--- a/daemon/gdm-simple-slave.c
+++ b/daemon/gdm-simple-slave.c
@@ -56,7 +56,6 @@
#define GDM_SIMPLE_SLAVE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SIMPLE_SLAVE,
GdmSimpleSlavePrivate))
-#define MAX_CONNECT_ATTEMPTS 10
#define DEFAULT_PING_INTERVAL 15
#define INITIAL_SETUP_USERNAME "gnome-initial-setup"
@@ -71,15 +70,12 @@ struct GdmSimpleSlavePrivate
int ping_interval;
GPid server_pid;
- guint connection_attempts;
/* this spawns and controls the greeter session */
GdmLaunchEnvironment *greeter_environment;
GDBusProxy *accountsservice_proxy;
guint have_existing_user_accounts : 1;
- guint accountsservice_ready : 1;
- guint waiting_to_connect_to_display : 1;
#ifdef HAVE_LOGINDEVPERM
gboolean use_logindevperm;
@@ -678,37 +674,6 @@ gdm_simple_slave_start_greeter_session (GdmSlave *slave)
}
}
-static gboolean
-idle_connect_to_display (GdmSimpleSlave *slave)
-{
- gboolean res;
-
- slave->priv->connection_attempts++;
-
- res = gdm_slave_connect_to_x11_display (GDM_SLAVE (slave));
- if (res) {
- setup_server (slave);
- } else {
- if (slave->priv->connection_attempts >= MAX_CONNECT_ATTEMPTS) {
- g_warning ("Unable to connect to display after %d tries - bailing out",
slave->priv->connection_attempts);
- exit (1);
- }
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-connect_to_display_when_accountsservice_ready (GdmSimpleSlave *slave)
-{
- if (slave->priv->accountsservice_ready) {
- slave->priv->waiting_to_connect_to_display = FALSE;
- g_idle_add ((GSourceFunc)idle_connect_to_display, slave);
- } else {
- slave->priv->waiting_to_connect_to_display = TRUE;
- }
-}
static void
on_list_cached_users_complete (GObject *proxy,
@@ -728,11 +693,7 @@ on_list_cached_users_complete (GObject *proxy,
g_variant_unref (call_result);
}
- slave->priv->accountsservice_ready = TRUE;
-
- if (slave->priv->waiting_to_connect_to_display) {
- connect_to_display_when_accountsservice_ready (slave);
- }
+ g_signal_emit_by_name (slave, "started");
}
static void
@@ -773,18 +734,6 @@ gdm_simple_slave_run (GdmSimpleSlave *slave)
/* if this is local display start a server if one doesn't
* exist */
if (display_is_local) {
- gboolean res;
-
- g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
- 0, NULL,
- "org.freedesktop.Accounts",
- "/org/freedesktop/Accounts",
- "org.freedesktop.Accounts",
- NULL,
- on_accountsservice_ready, slave);
- g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
- } else {
- g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
}
g_free (display_name);
@@ -798,7 +747,13 @@ gdm_simple_slave_start (GdmSlave *slave)
{
GDM_SLAVE_CLASS (gdm_simple_slave_parent_class)->start (slave);
- g_signal_emit_by_name (slave, "started");
+ g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
+ 0, NULL,
+ "org.freedesktop.Accounts",
+ "/org/freedesktop/Accounts",
+ "org.freedesktop.Accounts",
+ NULL,
+ on_accountsservice_ready, slave);
return TRUE;
}
diff --git a/daemon/gdm-slave.c b/daemon/gdm-slave.c
index 001ec5d..ea36508 100644
--- a/daemon/gdm-slave.c
+++ b/daemon/gdm-slave.c
@@ -61,8 +61,6 @@ struct GdmSlavePrivate
guint output_watch_id;
guint error_watch_id;
- Display *server_display;
-
char *session_id;
GdmDisplay *display;
@@ -106,95 +104,6 @@ static void gdm_slave_finalize (GObject *object);
G_DEFINE_ABSTRACT_TYPE (GdmSlave, gdm_slave, G_TYPE_OBJECT)
-static void
-gdm_slave_setup_xhost_auth (XHostAddress *host_entries, XServerInterpretedAddress *si_entries)
-{
- si_entries[0].type = "localuser";
- si_entries[0].typelength = strlen ("localuser");
- si_entries[1].type = "localuser";
- si_entries[1].typelength = strlen ("localuser");
- si_entries[2].type = "localuser";
- si_entries[2].typelength = strlen ("localuser");
-
- si_entries[0].value = "root";
- si_entries[0].valuelength = strlen ("root");
- si_entries[1].value = GDM_USERNAME;
- si_entries[1].valuelength = strlen (GDM_USERNAME);
- si_entries[2].value = "gnome-initial-setup";
- si_entries[2].valuelength = strlen ("gnome-initial-setup");
-
- host_entries[0].family = FamilyServerInterpreted;
- host_entries[0].address = (char *) &si_entries[0];
- host_entries[0].length = sizeof (XServerInterpretedAddress);
- host_entries[1].family = FamilyServerInterpreted;
- host_entries[1].address = (char *) &si_entries[1];
- host_entries[1].length = sizeof (XServerInterpretedAddress);
- host_entries[2].family = FamilyServerInterpreted;
- host_entries[2].address = (char *) &si_entries[2];
- host_entries[2].length = sizeof (XServerInterpretedAddress);
-}
-
-gboolean
-gdm_slave_connect_to_x11_display (GdmSlave *slave)
-{
- gboolean ret;
-
- ret = FALSE;
-
- /* We keep our own (windowless) connection (dsp) open to avoid the
- * X server resetting due to lack of active connections. */
-
- g_debug ("GdmSlave: Server is ready - opening display %s", slave->priv->display_name);
-
- /* Give slave access to the display independent of current hostname */
- if (slave->priv->display_x11_cookie != NULL) {
- XSetAuthorization ("MIT-MAGIC-COOKIE-1",
- strlen ("MIT-MAGIC-COOKIE-1"),
- (gpointer)
- g_bytes_get_data (slave->priv->display_x11_cookie, NULL),
- g_bytes_get_size (slave->priv->display_x11_cookie));
- }
-
- slave->priv->server_display = XOpenDisplay (slave->priv->display_name);
-
- if (slave->priv->server_display == NULL) {
- g_warning ("Unable to connect to display %s", slave->priv->display_name);
- ret = FALSE;
- } else if (slave->priv->display_is_local) {
- XServerInterpretedAddress si_entries[3];
- XHostAddress host_entries[3];
- int i;
-
- g_debug ("GdmSlave: Connected to display %s", slave->priv->display_name);
- ret = TRUE;
-
- /* Give programs run by the slave and greeter access to the
- * display independent of current hostname
- */
- gdm_slave_setup_xhost_auth (host_entries, si_entries);
-
- gdm_error_trap_push ();
-
- for (i = 0; i < G_N_ELEMENTS (host_entries); i++) {
- XAddHost (slave->priv->server_display, &host_entries[i]);
- }
-
- XSync (slave->priv->server_display, False);
- if (gdm_error_trap_pop ()) {
- g_warning ("Failed to give slave programs access to the display. Trying to
proceed.");
- }
- } else {
- g_debug ("GdmSlave: Connected to display %s", slave->priv->display_name);
- ret = TRUE;
- }
-
- if (ret) {
- g_signal_emit (slave, signals [STARTED], 0);
- }
-
- return ret;
-}
-
static gboolean
gdm_slave_real_start (GdmSlave *slave)
{
@@ -327,9 +236,6 @@ gdm_slave_add_user_authorization (GdmSlave *slave,
const char *username,
char **filenamep)
{
- XServerInterpretedAddress si_entries[3];
- XHostAddress host_entries[3];
- int i;
gboolean res;
GError *error;
char *filename;
@@ -360,19 +266,6 @@ gdm_slave_add_user_authorization (GdmSlave *slave,
}
g_free (filename);
- /* Remove access for the programs run by slave and greeter now that the
- * user session is starting.
- */
- gdm_slave_setup_xhost_auth (host_entries, si_entries);
- gdm_error_trap_push ();
- for (i = 0; i < G_N_ELEMENTS (host_entries); i++) {
- XRemoveHost (slave->priv->server_display, &host_entries[i]);
- }
- XSync (slave->priv->server_display, False);
- if (gdm_error_trap_pop ()) {
- g_warning ("Failed to remove slave program access to the display. Trying to proceed.");
- }
-
return res;
}
diff --git a/daemon/gdm-slave.h b/daemon/gdm-slave.h
index eefbca8..cb279d0 100644
--- a/daemon/gdm-slave.h
+++ b/daemon/gdm-slave.h
@@ -70,8 +70,6 @@ gboolean gdm_slave_add_user_authorization (GdmSlave *slave,
const char *username,
char **filename);
-gboolean gdm_slave_connect_to_x11_display (GdmSlave *slave);
-
void gdm_slave_set_up_greeter_session (GdmSlave *slave,
char **username);
void gdm_slave_start_greeter_session (GdmSlave *slave);
diff --git a/daemon/gdm-xdmcp-chooser-slave.c b/daemon/gdm-xdmcp-chooser-slave.c
index 4600935..06dbd49 100644
--- a/daemon/gdm-xdmcp-chooser-slave.c
+++ b/daemon/gdm-xdmcp-chooser-slave.c
@@ -60,8 +60,6 @@ struct GdmXdmcpChooserSlavePrivate
int ping_interval;
- guint connection_attempts;
-
GdmLaunchEnvironment *chooser_environment;
};
@@ -163,11 +161,6 @@ on_chooser_connected (GdmSession *session,
g_debug ("GdmXdmcpChooserSlave: Chooser connected");
}
-static void
-setup_server (GdmXdmcpChooserSlave *slave)
-{
-}
-
static GdmLaunchEnvironment *
create_chooser_session (const char *display_name,
const char *display_device,
@@ -279,54 +272,11 @@ run_chooser (GdmXdmcpChooserSlave *slave)
}
static gboolean
-idle_connect_to_display (GdmXdmcpChooserSlave *slave)
-{
- gboolean res;
-
- slave->priv->connection_attempts++;
-
- res = gdm_slave_connect_to_x11_display (GDM_SLAVE (slave));
- if (res) {
- /* FIXME: handle wait-for-go */
-
- setup_server (slave);
- run_chooser (slave);
- } else {
- if (slave->priv->connection_attempts >= MAX_CONNECT_ATTEMPTS) {
- g_warning ("Unable to connect to display after %d tries - bailing out",
slave->priv->connection_attempts);
- exit (1);
- }
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-gdm_xdmcp_chooser_slave_run (GdmXdmcpChooserSlave *slave)
-{
- char *display_name;
- char *auth_file;
-
- g_object_get (slave,
- "display-name", &display_name,
- "display-x11-authority-file", &auth_file,
- NULL);
-
- g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
-
- g_free (display_name);
- g_free (auth_file);
-
- return TRUE;
-}
-
-static gboolean
gdm_xdmcp_chooser_slave_start (GdmSlave *slave)
{
GDM_SLAVE_CLASS (gdm_xdmcp_chooser_slave_parent_class)->start (slave);
- gdm_xdmcp_chooser_slave_run (GDM_XDMCP_CHOOSER_SLAVE (slave));
+ run_chooser (GDM_XDMCP_CHOOSER_SLAVE (slave));
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]