diff options
author | Ray Strode <rstrode@redhat.com> | 2015-02-11 01:51:07 -0500 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2015-02-11 16:36:04 -0500 |
commit | 975d3097e88f09d088c323a6168aedc2a9f758dd (patch) | |
tree | b3feec72311d54fd2d77f85839d205cb627b942c | |
parent | 5c23da983a2dc8bd1ae5398545cb9e7a8590ff62 (diff) | |
download | gdm-wip/slave-display-merger.tar.gz |
slave: drop the slaveswip/slave-display-merger
At this point the slaves do nothing useful, so we can
get rid of them.
-rw-r--r-- | daemon/Makefile.am | 6 | ||||
-rw-r--r-- | daemon/gdm-display.c | 129 | ||||
-rw-r--r-- | daemon/gdm-display.h | 2 | ||||
-rw-r--r-- | daemon/gdm-manager.c | 14 | ||||
-rw-r--r-- | daemon/gdm-simple-slave.c | 67 | ||||
-rw-r--r-- | daemon/gdm-simple-slave.h | 54 | ||||
-rw-r--r-- | daemon/gdm-slave.c | 657 | ||||
-rw-r--r-- | daemon/gdm-slave.h | 83 | ||||
-rw-r--r-- | daemon/gdm-xdmcp-chooser-display.c | 2 | ||||
-rw-r--r-- | daemon/gdm-xdmcp-chooser-slave.c | 108 | ||||
-rw-r--r-- | daemon/gdm-xdmcp-chooser-slave.h | 55 |
11 files changed, 45 insertions, 1132 deletions
diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 949cf36a..fd7ac4a3 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -194,10 +194,6 @@ gdm_SOURCES = \ gdm-session-worker-common.h \ gdm-session-worker-job.c \ gdm-session-worker-job.h \ - gdm-slave.c \ - gdm-slave.h \ - gdm-simple-slave.c \ - gdm-simple-slave.h \ gdm-dbus-util.c \ gdm-dbus-util.h \ gdm-xerrors.c \ @@ -228,8 +224,6 @@ XDMCP_SOURCES = \ gdm-xdmcp-display.h \ gdm-xdmcp-chooser-display.c \ gdm-xdmcp-chooser-display.h \ - gdm-xdmcp-chooser-slave.c \ - gdm-xdmcp-chooser-slave.h \ $(NULL) if XDMCP_SUPPORT diff --git a/daemon/gdm-display.c b/daemon/gdm-display.c index 1c7cde2c..fa5ed773 100644 --- a/daemon/gdm-display.c +++ b/daemon/gdm-display.c @@ -47,8 +47,6 @@ #include "gdm-settings-keys.h" #include "gdm-launch-environment.h" -#include "gdm-simple-slave.h" -#include "gdm-xdmcp-chooser-slave.h" #include "gdm-dbus-util.h" #include "gdm-xerrors.h" @@ -68,8 +66,7 @@ struct GdmDisplayPrivate char *x11_display_name; int status; time_t creation_time; - GTimer *slave_timer; - GType slave_type; + GTimer *server_timer; char *x11_cookie; gsize x11_cookie_size; @@ -79,7 +76,6 @@ struct GdmDisplayPrivate Display *x11_display; - GdmSlave *slave; GDBusConnection *connection; GdmDisplayAccessFile *user_access_file; @@ -110,7 +106,6 @@ enum { PROP_X11_COOKIE, PROP_X11_AUTHORITY_FILE, PROP_IS_LOCAL, - PROP_SLAVE_TYPE, PROP_LAUNCH_ENVIRONMENT, PROP_IS_INITIAL, PROP_ALLOW_TIMED_LOGIN, @@ -377,7 +372,7 @@ gdm_display_add_user_authorization (GdmDisplay *self, self->priv->user_access_file = access_file; g_debug ("GdmDisplay: Added user authorization for %s: %s", username, *filename); - /* Remove access for the programs run by slave and greeter now that the + /* Remove access for the programs run by greeter now that the * user session is starting. */ setup_xhost_auth (host_entries, si_entries); @@ -387,7 +382,7 @@ gdm_display_add_user_authorization (GdmDisplay *self, } XSync (self->priv->x11_display, False); if (gdm_error_trap_pop ()) { - g_warning ("Failed to remove slave program access to the display. Trying to proceed."); + g_warning ("Failed to remove greeter program access to the display. Trying to proceed."); } return TRUE; @@ -602,13 +597,6 @@ queue_finish (GdmDisplay *self) } static void -on_slave_stopped (GdmSlave *slave, - GdmDisplay *self) -{ - queue_finish (self); -} - -static void _gdm_display_set_status (GdmDisplay *self, int status) { @@ -619,16 +607,9 @@ _gdm_display_set_status (GdmDisplay *self, } static void -on_slave_started (GdmSlave *slave, - GdmDisplay *self) -{ - _gdm_display_set_status (self, GDM_DISPLAY_MANAGED); -} - -static void gdm_display_real_start_server (GdmDisplay *self) { - gdm_slave_start (self->priv->slave); + _gdm_display_set_status (self, GDM_DISPLAY_MANAGED); } static gboolean @@ -646,17 +627,6 @@ gdm_display_real_prepare (GdmDisplay *self) _gdm_display_set_status (self, GDM_DISPLAY_PREPARED); - self->priv->slave = GDM_SLAVE (g_object_new (self->priv->slave_type, - "display", self, - NULL)); - g_signal_connect_object (self->priv->slave, "started", - G_CALLBACK (on_slave_started), - self, - 0); - g_signal_connect_object (self->priv->slave, "stopped", - G_CALLBACK (on_slave_stopped), - self, - 0); return TRUE; } @@ -706,7 +676,7 @@ on_accountsservice_ready (GObject *object, } static void -look_for_existing_users_and_start_slave (GdmDisplay *self) +look_for_existing_users_and_start_server (GdmDisplay *self) { g_dbus_proxy_new (self->priv->connection, 0, NULL, @@ -751,8 +721,8 @@ gdm_display_manage (GdmDisplay *self) } } - g_timer_start (self->priv->slave_timer); - look_for_existing_users_and_start_slave (self); + g_timer_start (self->priv->server_timer); + look_for_existing_users_and_start_server (self); return TRUE; } @@ -778,17 +748,7 @@ gdm_display_unmanage (GdmDisplay *self) g_debug ("GdmDisplay: unmanage display"); - g_timer_stop (self->priv->slave_timer); - - if (self->priv->slave != NULL) { - g_signal_handlers_disconnect_by_func (self->priv->slave, - G_CALLBACK (on_slave_started), self); - g_signal_handlers_disconnect_by_func (self->priv->slave, - G_CALLBACK (on_slave_stopped), self); - gdm_slave_stop (self->priv->slave); - g_object_unref (self->priv->slave); - self->priv->slave = NULL; - } + g_timer_stop (self->priv->server_timer); if (self->priv->user_access_file != NULL) { gdm_display_access_file_close (self->priv->user_access_file); @@ -802,7 +762,7 @@ gdm_display_unmanage (GdmDisplay *self) self->priv->access_file = NULL; } - elapsed = g_timer_elapsed (self->priv->slave_timer, NULL); + elapsed = g_timer_elapsed (self->priv->server_timer, NULL); if (elapsed < 3) { g_warning ("GdmDisplay: display lasted %lf seconds", elapsed); _gdm_display_set_status (self, GDM_DISPLAY_FAILED); @@ -918,13 +878,6 @@ _gdm_display_set_is_local (GdmDisplay *self, } static void -_gdm_display_set_slave_type (GdmDisplay *self, - GType type) -{ - self->priv->slave_type = type; -} - -static void _gdm_display_set_launch_environment (GdmDisplay *self, GdmLaunchEnvironment *launch_environment) { @@ -988,9 +941,6 @@ gdm_display_set_property (GObject *object, case PROP_ALLOW_TIMED_LOGIN: _gdm_display_set_allow_timed_login (self, g_value_get_boolean (value)); break; - case PROP_SLAVE_TYPE: - _gdm_display_set_slave_type (self, g_value_get_gtype (value)); - break; case PROP_LAUNCH_ENVIRONMENT: _gdm_display_set_launch_environment (self, g_value_get_object (value)); break; @@ -1045,9 +995,6 @@ gdm_display_get_property (GObject *object, case PROP_IS_LOCAL: g_value_set_boolean (value, self->priv->is_local); break; - case PROP_SLAVE_TYPE: - g_value_set_gtype (value, self->priv->slave_type); - break; case PROP_LAUNCH_ENVIRONMENT: g_value_set_object (value, self->priv->launch_environment); break; @@ -1364,7 +1311,6 @@ gdm_display_dispose (GObject *object) g_assert (self->priv->status == GDM_DISPLAY_FINISHED || self->priv->status == GDM_DISPLAY_FAILED); - g_assert (self->priv->slave == NULL); g_assert (self->priv->user_access_file == NULL); g_assert (self->priv->access_file == NULL); @@ -1480,13 +1426,6 @@ gdm_display_class_init (GdmDisplayClass *klass) GDM_TYPE_LAUNCH_ENVIRONMENT, G_PARAM_READWRITE)); g_object_class_install_property (object_class, - PROP_SLAVE_TYPE, - g_param_spec_gtype ("slave-type", - "slave type", - "slave type", - GDM_TYPE_SIMPLE_SLAVE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - g_object_class_install_property (object_class, PROP_STATUS, g_param_spec_int ("status", "status", @@ -1506,7 +1445,7 @@ gdm_display_init (GdmDisplay *self) self->priv = GDM_DISPLAY_GET_PRIVATE (self); self->priv->creation_time = time (NULL); - self->priv->slave_timer = g_timer_new (); + self->priv->server_timer = g_timer_new (); } static void @@ -1541,8 +1480,8 @@ gdm_display_finalize (GObject *object) g_object_unref (self->priv->user_access_file); } - if (self->priv->slave_timer != NULL) { - g_timer_destroy (self->priv->slave_timer); + if (self->priv->server_timer != NULL) { + g_timer_destroy (self->priv->server_timer); } G_OBJECT_CLASS (gdm_display_parent_class)->finalize (object); @@ -1574,13 +1513,25 @@ on_launch_environment_session_started (GdmLaunchEnvironment *launch_environment, } static void +self_destruct (GdmDisplay *self) +{ + g_object_ref (self); + if (gdm_display_get_status (self) == GDM_DISPLAY_MANAGED) { + gdm_display_unmanage (self); + } + + if (gdm_display_get_status (self) != GDM_DISPLAY_FINISHED) { + queue_finish (self); + } + g_object_unref (self); +} + +static void on_launch_environment_session_stopped (GdmLaunchEnvironment *launch_environment, GdmDisplay *self) { g_debug ("GdmDisplay: Greeter stopped"); - gdm_slave_stop (self->priv->slave); - - g_clear_object (&self->priv->launch_environment); + self_destruct (self); } static void @@ -1589,7 +1540,7 @@ on_launch_environment_session_exited (GdmLaunchEnvironment *launch_environment, GdmDisplay *self) { g_debug ("GdmDisplay: Greeter exited: %d", code); - gdm_slave_stop (self->priv->slave); + self_destruct (self); } static void @@ -1598,7 +1549,7 @@ on_launch_environment_session_died (GdmLaunchEnvironment *launch_environment, GdmDisplay *self) { g_debug ("GdmDisplay: Greeter died: %d", signal); - gdm_slave_stop (self->priv->slave); + self_destruct (self); } static gboolean @@ -1760,6 +1711,22 @@ void gdm_display_stop_greeter_session (GdmDisplay *self) { if (self->priv->launch_environment != NULL) { + + g_signal_handlers_disconnect_by_func (self->priv->launch_environment, + G_CALLBACK (on_launch_environment_session_opened), + self); + g_signal_handlers_disconnect_by_func (self->priv->launch_environment, + G_CALLBACK (on_launch_environment_session_started), + self); + g_signal_handlers_disconnect_by_func (self->priv->launch_environment, + G_CALLBACK (on_launch_environment_session_stopped), + self); + g_signal_handlers_disconnect_by_func (self->priv->launch_environment, + G_CALLBACK (on_launch_environment_session_exited), + self); + g_signal_handlers_disconnect_by_func (self->priv->launch_environment, + G_CALLBACK (on_launch_environment_session_died), + self); gdm_launch_environment_stop (self->priv->launch_environment); g_clear_object (&self->priv->launch_environment); } @@ -1769,12 +1736,6 @@ gdm_display_stop_greeter_session (GdmDisplay *self) } } -GdmSlave * -gdm_display_get_slave (GdmDisplay *self) -{ - return self->priv->slave; -} - static void gdm_display_set_windowpath (GdmDisplay *self) { diff --git a/daemon/gdm-display.h b/daemon/gdm-display.h index f6919795..8beea444 100644 --- a/daemon/gdm-display.h +++ b/daemon/gdm-display.h @@ -24,7 +24,6 @@ #include <glib-object.h> #include <gio/gio.h> -#include "gdm-slave.h" G_BEGIN_DECLS @@ -141,7 +140,6 @@ void gdm_display_set_up_greeter_session (GdmDisplay *dis char **username); void gdm_display_start_greeter_session (GdmDisplay *display); void gdm_display_stop_greeter_session (GdmDisplay *display); -GdmSlave * gdm_display_get_slave (GdmDisplay *display); gboolean gdm_display_connect (GdmDisplay *self); diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c index 085f1c4a..f4e6aaeb 100644 --- a/daemon/gdm-manager.c +++ b/daemon/gdm-manager.c @@ -1579,21 +1579,7 @@ on_session_started (GdmSession *session, GPid pid, GdmManager *manager) { - GdmDisplay *display; - g_debug ("GdmManager: session started %d", pid); - - display = get_display_for_user_session (session); - - if (display != NULL) { - GdmSlave *slave; - const char *session_id; - - slave = gdm_display_get_slave (display); - - session_id = gdm_session_get_session_id (session); - g_object_set (GDM_SLAVE (slave), "session-id", session_id, NULL); - } } static void diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c deleted file mode 100644 index e5c88740..00000000 --- a/daemon/gdm-simple-slave.c +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" - -#include <stdlib.h> -#include <stdio.h> -#include <fcntl.h> -#include <unistd.h> -#include <string.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <errno.h> - -#include <glib.h> -#include <glib/gi18n.h> -#include <glib/gstdio.h> -#include <glib-object.h> - -#include <X11/Xlib.h> /* for Display */ - -#include <act/act-user-manager.h> - -#include "gdm-common.h" - -#include "gdm-settings-keys.h" - -#include "gdm-simple-slave.h" - -#include "gdm-server.h" -#include "gdm-session.h" -#include "gdm-session-glue.h" -#include "gdm-launch-environment.h" -#include "gdm-settings-direct.h" -#include "gdm-settings-keys.h" - -static void gdm_simple_slave_class_init (GdmSimpleSlaveClass *klass); -static void gdm_simple_slave_init (GdmSimpleSlave *simple_slave); - -G_DEFINE_TYPE (GdmSimpleSlave, gdm_simple_slave, GDM_TYPE_SLAVE) - -static void -gdm_simple_slave_class_init (GdmSimpleSlaveClass *klass) -{ -} - -static void -gdm_simple_slave_init (GdmSimpleSlave *slave) -{ -} diff --git a/daemon/gdm-simple-slave.h b/daemon/gdm-simple-slave.h deleted file mode 100644 index 376aedab..00000000 --- a/daemon/gdm-simple-slave.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - - -#ifndef __GDM_SIMPLE_SLAVE_H -#define __GDM_SIMPLE_SLAVE_H - -#include <glib-object.h> -#include "gdm-slave.h" - -G_BEGIN_DECLS - -#define GDM_TYPE_SIMPLE_SLAVE (gdm_simple_slave_get_type ()) -#define GDM_SIMPLE_SLAVE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDM_TYPE_SIMPLE_SLAVE, GdmSimpleSlave)) -#define GDM_SIMPLE_SLAVE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_SIMPLE_SLAVE, GdmSimpleSlaveClass)) -#define GDM_IS_SIMPLE_SLAVE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_SIMPLE_SLAVE)) -#define GDM_IS_SIMPLE_SLAVE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_SIMPLE_SLAVE)) -#define GDM_SIMPLE_SLAVE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_SIMPLE_SLAVE, GdmSimpleSlaveClass)) - -typedef struct GdmSimpleSlavePrivate GdmSimpleSlavePrivate; - -typedef struct -{ - GdmSlave parent; - GdmSimpleSlavePrivate *priv; -} GdmSimpleSlave; - -typedef struct -{ - GdmSlaveClass parent_class; -} GdmSimpleSlaveClass; - -GType gdm_simple_slave_get_type (void); - -G_END_DECLS - -#endif /* __GDM_SIMPLE_SLAVE_H */ diff --git a/daemon/gdm-slave.c b/daemon/gdm-slave.c deleted file mode 100644 index 7c1b5af2..00000000 --- a/daemon/gdm-slave.c +++ /dev/null @@ -1,657 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" - -#include <stdlib.h> -#include <stdio.h> -#include <stdint.h> -#include <fcntl.h> -#include <unistd.h> -#include <string.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <errno.h> -#include <pwd.h> -#include <grp.h> - -#include <glib.h> -#include <glib/gstdio.h> -#include <glib/gi18n.h> -#include <glib-object.h> - -#include <X11/Xlib.h> /* for Display */ -#include <X11/Xatom.h> /* for XA_PIXMAP */ -#include <X11/cursorfont.h> /* for watch cursor */ -#include <X11/Xatom.h> - -#ifdef WITH_SYSTEMD -#include <systemd/sd-login.h> -#endif - -#include "gdm-common.h" -#include "gdm-xerrors.h" - -#include "gdm-slave.h" -#include "gdm-display.h" -#include "gdm-display-glue.h" - -#include "gdm-server.h" - -#define GDM_SLAVE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SLAVE, GdmSlavePrivate)) - -struct GdmSlavePrivate -{ - GPid pid; - guint output_watch_id; - guint error_watch_id; - - char *session_id; - - GdmDisplay *display; - - /* cached display values */ - char *display_name; - int display_number; - char *display_hostname; - gboolean display_is_local; - char *display_seat_id; - char *display_x11_authority_file; - GBytes *display_x11_cookie; - gboolean display_is_initial; -}; - -enum { - PROP_0, - PROP_SESSION_ID, - PROP_DISPLAY, - PROP_DISPLAY_NAME, - PROP_DISPLAY_NUMBER, - PROP_DISPLAY_HOSTNAME, - PROP_DISPLAY_IS_LOCAL, - PROP_DISPLAY_SEAT_ID, - PROP_DISPLAY_X11_AUTHORITY_FILE, - PROP_DISPLAY_IS_INITIAL, -}; - -enum { - STARTED, - STOPPED, - LAST_SIGNAL -}; - -static guint signals [LAST_SIGNAL] = { 0, }; - -static void gdm_slave_class_init (GdmSlaveClass *klass); -static void gdm_slave_init (GdmSlave *slave); -static void gdm_slave_finalize (GObject *object); - -G_DEFINE_ABSTRACT_TYPE (GdmSlave, gdm_slave, G_TYPE_OBJECT) - -#define CURSOR_WATCH XC_watch - -GQuark -gdm_slave_error_quark (void) -{ - static GQuark ret = 0; - if (ret == 0) { - ret = g_quark_from_static_string ("gdm-slave-error-quark"); - } - - return ret; -} - -gboolean -gdm_slave_connect_to_x11_display (GdmSlave *slave) -{ - gboolean ret; - - ret = gdm_display_connect (slave->priv->display); - - if (ret) { - g_signal_emit (slave, signals [STARTED], 0); - } - - return ret; -} - -static gboolean -gdm_slave_real_start (GdmSlave *slave) -{ - gboolean res; - GError *error; - const char *x11_cookie; - gsize x11_cookie_size; - - g_debug ("GdmSlave: Starting slave"); - - /* cache some values up front */ - error = NULL; - res = gdm_display_is_local (slave->priv->display, &slave->priv->display_is_local, &error); - if (! res) { - g_warning ("Failed to get value: %s", error->message); - g_error_free (error); - return FALSE; - } - - error = NULL; - res = gdm_display_get_x11_display_name (slave->priv->display, &slave->priv->display_name, &error); - if (! res) { - g_warning ("Failed to get value: %s", error->message); - g_error_free (error); - return FALSE; - } - - error = NULL; - res = gdm_display_get_x11_display_number (slave->priv->display, &slave->priv->display_number, &error); - if (! res) { - g_warning ("Failed to get value: %s", error->message); - g_error_free (error); - return FALSE; - } - - error = NULL; - res = gdm_display_get_remote_hostname (slave->priv->display, &slave->priv->display_hostname, &error); - if (! res) { - g_warning ("Failed to get value: %s", error->message); - g_error_free (error); - return FALSE; - } - - error = NULL; - res = gdm_display_get_x11_cookie (slave->priv->display, &x11_cookie, &x11_cookie_size, &error); - if (! res) { - g_warning ("Failed to get value: %s", error->message); - g_error_free (error); - return FALSE; - } - - if (x11_cookie != NULL && x11_cookie_size > 0) { - g_bytes_unref (slave->priv->display_x11_cookie); - slave->priv->display_x11_cookie = g_bytes_new (x11_cookie, x11_cookie_size); - } - - error = NULL; - res = gdm_display_get_x11_authority_file (slave->priv->display, &slave->priv->display_x11_authority_file, &error); - if (! res) { - g_warning ("Failed to get value: %s", error->message); - g_error_free (error); - return FALSE; - } - - error = NULL; - res = gdm_display_get_seat_id (slave->priv->display, &slave->priv->display_seat_id, &error); - if (! res) { - g_warning ("Failed to get value: %s", error->message); - g_error_free (error); - return FALSE; - } - - error = NULL; - res = gdm_display_is_initial (slave->priv->display, &slave->priv->display_is_initial, &error); - if (! res) { - g_warning ("Failed to get value: %s", error->message); - g_error_free (error); - return FALSE; - } - - return TRUE; -} - -static gboolean -gdm_slave_real_stop (GdmSlave *slave) -{ - g_debug ("GdmSlave: Stopping slave"); - - g_clear_object (&slave->priv->display); - - return TRUE; -} - -gboolean -gdm_slave_start (GdmSlave *slave) -{ - gboolean ret; - - g_return_val_if_fail (GDM_IS_SLAVE (slave), FALSE); - - g_debug ("GdmSlave: starting slave"); - - g_object_ref (slave); - ret = GDM_SLAVE_GET_CLASS (slave)->start (slave); - g_object_unref (slave); - - return ret; -} - -gboolean -gdm_slave_stop (GdmSlave *slave) -{ - gboolean ret; - - g_return_val_if_fail (GDM_IS_SLAVE (slave), FALSE); - - g_debug ("GdmSlave: stopping slave"); - - g_object_ref (slave); - - ret = GDM_SLAVE_GET_CLASS (slave)->stop (slave); - g_signal_emit (slave, signals [STOPPED], 0); - - g_object_unref (slave); - return ret; -} - -gboolean -gdm_slave_add_user_authorization (GdmSlave *slave, - const char *username, - char **filenamep) -{ - gboolean res; - GError *error; - char *filename; - - filename = NULL; - - if (filenamep != NULL) { - *filenamep = NULL; - } - - g_debug ("GdmSlave: Requesting user authorization"); - - error = NULL; - res = gdm_display_add_user_authorization (slave->priv->display, - username, - &filename, - &error); - - if (! res) { - g_warning ("Failed to add user authorization: %s", error->message); - g_error_free (error); - } else { - g_debug ("GdmSlave: Got user authorization: %s", filename); - } - - if (filenamep != NULL) { - *filenamep = g_strdup (filename); - } - g_free (filename); - - return res; -} - -static char * -gdm_slave_parse_enriched_login (GdmSlave *slave, - const char *username) -{ - char **argv; - int username_len; - GPtrArray *env; - GError *error; - gboolean res; - char *parsed_username; - char *command; - char *std_output; - char *std_error; - - parsed_username = NULL; - - if (username == NULL || username[0] == '\0') { - return NULL; - } - - /* A script may be used to generate the automatic/timed login name - based on the display/host by ending the name with the pipe symbol - '|'. */ - - username_len = strlen (username); - if (username[username_len - 1] != '|') { - return g_strdup (username); - } - - /* Remove the pipe symbol */ - command = g_strndup (username, username_len - 1); - - argv = NULL; - error = NULL; - if (! g_shell_parse_argv (command, NULL, &argv, &error)) { - g_warning ("GdmSlave: Could not parse command '%s': %s", command, error->message); - g_error_free (error); - - g_free (command); - goto out; - } - - g_debug ("GdmSlave: running '%s' to acquire auto/timed username", command); - g_free (command); - - env = gdm_get_script_environment (username, - slave->priv->display_name, - slave->priv->display_hostname, - slave->priv->display_x11_authority_file); - - error = NULL; - std_output = NULL; - std_error = NULL; - res = g_spawn_sync (NULL, - argv, - (char **)env->pdata, - G_SPAWN_SEARCH_PATH, - NULL, - NULL, - &std_output, - &std_error, - NULL, - &error); - - g_ptr_array_foreach (env, (GFunc)g_free, NULL); - g_ptr_array_free (env, TRUE); - g_strfreev (argv); - - if (! res) { - g_warning ("GdmSlave: Unable to launch auto/timed login script '%s': %s", username, error->message); - g_error_free (error); - - g_free (std_output); - g_free (std_error); - goto out; - } - - if (std_output != NULL) { - g_strchomp (std_output); - if (std_output[0] != '\0') { - parsed_username = g_strdup (std_output); - } - } - - out: - return parsed_username; -} - -gboolean -gdm_slave_get_timed_login_details (GdmSlave *slave, - gboolean *enabledp, - char **usernamep, - int *delayp) -{ - struct passwd *pwent; - gboolean enabled; - char *username; - int delay; - - username = NULL; - enabled = FALSE; - delay = 0; - - g_debug ("GdmSlave: Requesting timed login details"); - - gdm_display_get_timed_login_details (slave->priv->display, - &enabled, - &username, - &delay); - - g_debug ("GdmSlave: Got timed login details: %d %s %d", enabled, username, delay); - - if (usernamep != NULL) { - *usernamep = gdm_slave_parse_enriched_login (slave, username); - } else { - g_free (username); - - if (enabledp != NULL) { - *enabledp = enabled; - } - if (delayp != NULL) { - *delayp = delay; - } - return TRUE; - } - g_free (username); - - if (usernamep != NULL && *usernamep != NULL) { - gdm_get_pwent_for_name (*usernamep, &pwent); - if (pwent == NULL) { - g_debug ("Invalid username %s for auto/timed login", - *usernamep); - g_free (*usernamep); - *usernamep = NULL; - } else { - g_debug ("Using username %s for auto/timed login", - *usernamep); - - if (enabledp != NULL) { - *enabledp = enabled; - } - if (delayp != NULL) { - *delayp = delay; - } - } - } else { - g_debug ("Invalid NULL username for auto/timed login"); - } - - return TRUE; -} - -static void -_gdm_slave_set_session_id (GdmSlave *slave, - const char *id) -{ - g_free (slave->priv->session_id); - slave->priv->session_id = g_strdup (id); -} - -static void -gdm_slave_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GdmSlave *self; - - self = GDM_SLAVE (object); - - switch (prop_id) { - case PROP_SESSION_ID: - _gdm_slave_set_session_id (self, g_value_get_string (value)); - break; - case PROP_DISPLAY: - self->priv->display = g_value_dup_object (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gdm_slave_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GdmSlave *self; - - self = GDM_SLAVE (object); - - switch (prop_id) { - case PROP_SESSION_ID: - g_value_set_string (value, self->priv->session_id); - break; - case PROP_DISPLAY: - g_value_set_object (value, self->priv->display); - break; - case PROP_DISPLAY_NAME: - g_value_set_string (value, self->priv->display_name); - break; - case PROP_DISPLAY_NUMBER: - g_value_set_int (value, self->priv->display_number); - break; - case PROP_DISPLAY_HOSTNAME: - g_value_set_string (value, self->priv->display_hostname); - break; - case PROP_DISPLAY_SEAT_ID: - g_value_set_string (value, self->priv->display_seat_id); - break; - case PROP_DISPLAY_X11_AUTHORITY_FILE: - g_value_set_string (value, self->priv->display_x11_authority_file); - break; - case PROP_DISPLAY_IS_LOCAL: - g_value_set_boolean (value, self->priv->display_is_local); - break; - case PROP_DISPLAY_IS_INITIAL: - g_value_set_boolean (value, self->priv->display_is_initial); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gdm_slave_class_init (GdmSlaveClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->get_property = gdm_slave_get_property; - object_class->set_property = gdm_slave_set_property; - object_class->finalize = gdm_slave_finalize; - - klass->start = gdm_slave_real_start; - klass->stop = gdm_slave_real_stop; - - g_type_class_add_private (klass, sizeof (GdmSlavePrivate)); - - g_object_class_install_property (object_class, - PROP_SESSION_ID, - g_param_spec_string ("session-id", - "Session id", - "ID of session", - NULL, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_DISPLAY, - g_param_spec_object ("display", - "id", - "id", - GDM_TYPE_DISPLAY, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property (object_class, - PROP_DISPLAY_NAME, - g_param_spec_string ("display-name", - "display name", - "display name", - NULL, - G_PARAM_READABLE)); - g_object_class_install_property (object_class, - PROP_DISPLAY_NUMBER, - g_param_spec_int ("display-number", - "display number", - "display number", - -1, - G_MAXINT, - -1, - G_PARAM_READABLE)); - g_object_class_install_property (object_class, - PROP_DISPLAY_HOSTNAME, - g_param_spec_string ("display-hostname", - "display hostname", - "display hostname", - NULL, - G_PARAM_READABLE)); - g_object_class_install_property (object_class, - PROP_DISPLAY_SEAT_ID, - g_param_spec_string ("display-seat-id", - "", - "", - NULL, - G_PARAM_READABLE)); - g_object_class_install_property (object_class, - PROP_DISPLAY_X11_AUTHORITY_FILE, - g_param_spec_string ("display-x11-authority-file", - "", - "", - NULL, - G_PARAM_READABLE)); - g_object_class_install_property (object_class, - PROP_DISPLAY_IS_LOCAL, - g_param_spec_boolean ("display-is-local", - "display is local", - "display is local", - TRUE, - G_PARAM_READABLE)); - g_object_class_install_property (object_class, - PROP_DISPLAY_IS_INITIAL, - g_param_spec_boolean ("display-is-initial", - NULL, - NULL, - FALSE, - G_PARAM_READABLE)); - - signals [STARTED] = - g_signal_new ("started", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, - NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - - signals [STOPPED] = - g_signal_new ("stopped", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdmSlaveClass, stopped), - NULL, - NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); -} - -static void -gdm_slave_init (GdmSlave *slave) -{ - slave->priv = GDM_SLAVE_GET_PRIVATE (slave); - - slave->priv->pid = -1; -} - -static void -gdm_slave_finalize (GObject *object) -{ - GdmSlave *slave; - - g_return_if_fail (object != NULL); - g_return_if_fail (GDM_IS_SLAVE (object)); - - slave = GDM_SLAVE (object); - - g_return_if_fail (slave->priv != NULL); - - g_free (slave->priv->display_name); - g_free (slave->priv->display_hostname); - g_free (slave->priv->display_seat_id); - g_free (slave->priv->display_x11_authority_file); - g_bytes_unref (slave->priv->display_x11_cookie); - - G_OBJECT_CLASS (gdm_slave_parent_class)->finalize (object); -} diff --git a/daemon/gdm-slave.h b/daemon/gdm-slave.h deleted file mode 100644 index e0033191..00000000 --- a/daemon/gdm-slave.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- - * - * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - - -#ifndef __GDM_SLAVE_H -#define __GDM_SLAVE_H - -#include <glib-object.h> -#include <gio/gio.h> - -G_BEGIN_DECLS - -#define GDM_TYPE_SLAVE (gdm_slave_get_type ()) -#define GDM_SLAVE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDM_TYPE_SLAVE, GdmSlave)) -#define GDM_SLAVE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_SLAVE, GdmSlaveClass)) -#define GDM_IS_SLAVE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_SLAVE)) -#define GDM_IS_SLAVE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_SLAVE)) -#define GDM_SLAVE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_SLAVE, GdmSlaveClass)) - -typedef struct GdmSlavePrivate GdmSlavePrivate; - -typedef struct -{ - GObject parent; - GdmSlavePrivate *priv; -} GdmSlave; - -typedef struct -{ - GObjectClass parent_class; - - /* methods */ - gboolean (*start) (GdmSlave *slave); - gboolean (*stop) (GdmSlave *slave); - - /* signals */ - void (*stopped) (GdmSlave *slave); -} GdmSlaveClass; - -typedef enum -{ - GDM_SLAVE_ERROR_GENERIC, - GDM_SLAVE_ERROR_UNSUPPORTED, - GDM_SLAVE_ERROR_NOT_OPENED, - GDM_SLAVE_ERROR_WRONG_SESSION, -} GdmSlaveError; - -#define GDM_SLAVE_ERROR (gdm_slave_error_quark ()) - -GQuark gdm_slave_error_quark (void); -GType gdm_slave_get_type (void); -gboolean gdm_slave_start (GdmSlave *slave); -gboolean gdm_slave_stop (GdmSlave *slave); -gboolean gdm_slave_get_timed_login_details (GdmSlave *slave, - gboolean *enabled, - char **username, - int *delay); -gboolean gdm_slave_add_user_authorization (GdmSlave *slave, - const char *username, - char **filename); - -gboolean gdm_slave_connect_to_x11_display (GdmSlave *slave); - -G_END_DECLS - -#endif /* __GDM_SLAVE_H */ diff --git a/daemon/gdm-xdmcp-chooser-display.c b/daemon/gdm-xdmcp-chooser-display.c index 711751bb..d593cb44 100644 --- a/daemon/gdm-xdmcp-chooser-display.c +++ b/daemon/gdm-xdmcp-chooser-display.c @@ -38,7 +38,6 @@ #include "gdm-display.h" #include "gdm-launch-environment.h" #include "gdm-xdmcp-chooser-display.h" -#include "gdm-xdmcp-chooser-slave.h" #include "gdm-common.h" #include "gdm-address.h" @@ -134,7 +133,6 @@ gdm_xdmcp_chooser_display_new (const char *hostname, x11_display = g_strdup_printf ("%s:%d", hostname, number); object = g_object_new (GDM_TYPE_XDMCP_CHOOSER_DISPLAY, - "slave-type", GDM_TYPE_XDMCP_CHOOSER_SLAVE, "remote-hostname", hostname, "x11-display-number", number, "x11-display-name", x11_display, diff --git a/daemon/gdm-xdmcp-chooser-slave.c b/daemon/gdm-xdmcp-chooser-slave.c deleted file mode 100644 index bec5deb0..00000000 --- a/daemon/gdm-xdmcp-chooser-slave.c +++ /dev/null @@ -1,108 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- - * - * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" - -#include <stdlib.h> -#include <stdio.h> -#include <fcntl.h> -#include <unistd.h> -#include <string.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <errno.h> - -#include <glib.h> -#include <glib/gi18n.h> -#include <glib/gstdio.h> -#include <glib-object.h> - -#include <X11/Xlib.h> /* for Display */ - -#include "gdm-common.h" - -#include "gdm-xdmcp-chooser-slave.h" - -#include "gdm-server.h" -#include "gdm-launch-environment.h" -#include "gdm-settings-direct.h" -#include "gdm-settings-keys.h" -#include "gdm-session.h" - -#define GDM_XDMCP_CHOOSER_SLAVE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_XDMCP_CHOOSER_SLAVE, GdmXdmcpChooserSlavePrivate)) - -#define GDM_DBUS_NAME "org.gnome.DisplayManager" -#define GDM_DBUS_DISPLAY_INTERFACE "org.gnome.DisplayManager.Display" - -#define MAX_CONNECT_ATTEMPTS 10 -#define DEFAULT_PING_INTERVAL 15 - -struct GdmXdmcpChooserSlavePrivate -{ - char *id; - GPid pid; - - int ping_interval; - - guint connection_attempts; -}; - -enum { - LAST_SIGNAL -}; - -static guint signals [LAST_SIGNAL] = { 0, }; - -static void gdm_xdmcp_chooser_slave_class_init (GdmXdmcpChooserSlaveClass *klass); -static void gdm_xdmcp_chooser_slave_init (GdmXdmcpChooserSlave *xdmcp_chooser_slave); -static void gdm_xdmcp_chooser_slave_finalize (GObject *object); - -G_DEFINE_TYPE (GdmXdmcpChooserSlave, gdm_xdmcp_chooser_slave, GDM_TYPE_SLAVE) - -static void -gdm_xdmcp_chooser_slave_class_init (GdmXdmcpChooserSlaveClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = gdm_xdmcp_chooser_slave_finalize; - - g_type_class_add_private (klass, sizeof (GdmXdmcpChooserSlavePrivate)); -} - -static void -gdm_xdmcp_chooser_slave_init (GdmXdmcpChooserSlave *slave) -{ - slave->priv = GDM_XDMCP_CHOOSER_SLAVE_GET_PRIVATE (slave); -} - -static void -gdm_xdmcp_chooser_slave_finalize (GObject *object) -{ - GdmXdmcpChooserSlave *xdmcp_chooser_slave; - - g_return_if_fail (object != NULL); - g_return_if_fail (GDM_IS_XDMCP_CHOOSER_SLAVE (object)); - - xdmcp_chooser_slave = GDM_XDMCP_CHOOSER_SLAVE (object); - - g_return_if_fail (xdmcp_chooser_slave->priv != NULL); - - G_OBJECT_CLASS (gdm_xdmcp_chooser_slave_parent_class)->finalize (object); -} diff --git a/daemon/gdm-xdmcp-chooser-slave.h b/daemon/gdm-xdmcp-chooser-slave.h deleted file mode 100644 index b948ef8d..00000000 --- a/daemon/gdm-xdmcp-chooser-slave.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- - * - * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - - -#ifndef __GDM_XDMCP_CHOOSER_SLAVE_H -#define __GDM_XDMCP_CHOOSER_SLAVE_H - -#include <glib-object.h> -#include "gdm-slave.h" - -G_BEGIN_DECLS - -#define GDM_TYPE_XDMCP_CHOOSER_SLAVE (gdm_xdmcp_chooser_slave_get_type ()) -#define GDM_XDMCP_CHOOSER_SLAVE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDM_TYPE_XDMCP_CHOOSER_SLAVE, GdmXdmcpChooserSlave)) -#define GDM_XDMCP_CHOOSER_SLAVE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_XDMCP_CHOOSER_SLAVE, GdmXdmcpChooserSlaveClass)) -#define GDM_IS_XDMCP_CHOOSER_SLAVE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_XDMCP_CHOOSER_SLAVE)) -#define GDM_IS_XDMCP_CHOOSER_SLAVE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_XDMCP_CHOOSER_SLAVE)) -#define GDM_XDMCP_CHOOSER_SLAVE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_XDMCP_CHOOSER_SLAVE, GdmXdmcpChooserSlaveClass)) - -typedef struct GdmXdmcpChooserSlavePrivate GdmXdmcpChooserSlavePrivate; - -typedef struct -{ - GdmSlave parent; - GdmXdmcpChooserSlavePrivate *priv; -} GdmXdmcpChooserSlave; - -typedef struct -{ - GdmSlaveClass parent_class; - -} GdmXdmcpChooserSlaveClass; - -GType gdm_xdmcp_chooser_slave_get_type (void); - -G_END_DECLS - -#endif /* __GDM_XDMCP_CHOOSER_SLAVE_H */ |