15420N/A@@ -5,3 +5,4 @@ VOID:STRING,STRING
15420N/A+VOID:STRING,STRING,STRING,POINTER,STRING,POINTER
15420N/A@@ -303,7 +303,7 @@ AC_CHECK_TYPE(socklen_t,,
15420N/A-AC_CHECK_FUNCS([setresuid setenv unsetenv clearenv])
15420N/A+AC_CHECK_FUNCS([setresuid setenv unsetenv clearenv strrep])
15420N/A dnl checks needed for Darwin compatibility to linux **environ.
15420N/A@@ -1091,105 +1091,6 @@ AC_CHECK_LIB(devinfo, di_devperm_login, [
15420N/A PAM_LIBS="$PAM_LIBS -ldevinfo" ])
15420N/A dnl ---------------------------------------------------------------------------
17388N/A-dnl - Check for X Server location
16052N/A-dnl ---------------------------------------------------------------------------
18572N/A-# symlink to each other, and configure should use the more stable
18572N/A-# location (the real directory) if possible.
18572N/A-# use Xsun or Xorg, so this is used on Solaris.
18572N/A-# should use the more stable location (the real directory) if possible.
- # Xserver. We add this to the path below.
- X_CONFIG_OPTIONS="-audit 0 -nobanner"
- X_CONFIG_OPTIONS="-audit 0"
- X_CONFIG_OPTIONS="-audit 0"
- # what to do, what to do, this is wrong, but this just sets the
- # defaults, perhaps this user is cross compiling or some such
- X_CONFIG_OPTIONS="-audit 0"
-dnl ---------------------------------------------------------------------------
-dnl - Check for Xnest / Xephyr support
-dnl ---------------------------------------------------------------------------
-# Use Xephyr if it is available. It works better than Xnest since Xephyr
-# supports the Xserver extensions, even if on a remote machine.
-X_XNEST_UNSCALED_FONTPATH="true"
- X_XNEST_CONFIG_OPTIONS="-audit 0"
- # If on Solaris, Xnest is only shipped with the Xsun Xserver, so
- X_XNEST_CONFIG_OPTIONS="-audit 0 -name Xnest -pn"
- X_XNEST_UNSCALED_FONTPATH="false"
- X_XNEST_CONFIG_OPTIONS="-audit 0 -name Xnest"
-dnl ---------------------------------------------------------------------------
dnl ---------------------------------------------------------------------------
@@ -1353,6 +1254,21 @@ else
+dnl ---------------------------------------------------------------------------
+dnl ---------------------------------------------------------------------------
+AC_ARG_WITH(script-path,
+ AS_HELP_STRING([--with-script-path=<dir>],
+if ! test -z "$with_script_path"; then
+ SCRIPT_PATH=$with_script_path
# Set configuration choices.
@@ -1360,21 +1276,6 @@ AC_DEFINE_UNQUOTED(XSESSION_SHELL,"$XSESSION_SHELL",[xsession shell])
AC_DEFINE_UNQUOTED(SOUND_PROGRAM,"$SOUND_PROGRAM",[])
-AC_SUBST(X_CONFIG_OPTIONS)
-AC_DEFINE_UNQUOTED(X_SERVER,"$X_SERVER",[])
-AC_DEFINE_UNQUOTED(X_SERVER_PATH,"$X_SERVER_PATH",[])
-AC_DEFINE_UNQUOTED(X_CONFIG_OPTIONS,"$X_CONFIG_OPTIONS", [Options used when launching xserver])
-AC_SUBST(X_XNEST_CONFIG_OPTIONS)
-AC_SUBST(X_XNEST_UNSCALED_FONTPATH)
-AC_DEFINE_UNQUOTED(X_XNEST_CMD,"$X_XNEST_CMD",[])
-AC_DEFINE_UNQUOTED(X_XNEST_CONFIG_OPTIONS,"$X_XNEST_CONFIG_OPTIONS",[])
-AC_DEFINE_UNQUOTED(X_XNEST_UNSCALED_FONTPATH,"$X_XNEST_UNSCALED_FONTPATH",[])
@@ -1442,7 +1346,7 @@ echo "
PAM prefix: ${PAM_PREFIX}
+ script path: ${SCRIPT_PATH}
dnl TCP Wrappers support?
index ee69010..2afb2fb 100644
@@ -292,6 +292,8 @@ gdm_binary_SOURCES = \
index 0117eb9..8609ccb 100644
@@ -65,6 +65,7 @@ struct _CkConnector
dbus_bool_t session_created;
DBusConnection *connection;
@@ -76,8 +77,11 @@ static struct {
{ "display-device", DBUS_TYPE_STRING },
{ "x11-display-device", DBUS_TYPE_STRING },
{ "x11-display", DBUS_TYPE_STRING },
+ { "seat-id", DBUS_TYPE_STRING },
+ { "session", DBUS_TYPE_STRING },
{ "remote-host-name", DBUS_TYPE_STRING },
{ "session-type", DBUS_TYPE_STRING },
+ { "display-type", DBUS_TYPE_STRING },
{ "is-local", DBUS_TYPE_BOOLEAN },
{ "unix-user", DBUS_TYPE_INT32 },
@@ -181,6 +185,10 @@ _ck_connector_free (CkConnector *connector)
free (connector->cookie);
+ if (connector->session_id != NULL) {
+ free (connector->session_id);
@@ -241,6 +249,7 @@ ck_connector_new (void)
connector->connection = NULL;
connector->cookie = NULL;
+ connector->session_id = NULL;
connector->session_created = FALSE;
@@ -266,6 +275,7 @@ ck_connector_open_session (CkConnector *connector,
_ck_return_val_if_fail (connector != NULL, FALSE);
_ck_return_val_if_fail ((error) == NULL || !dbus_error_is_set ((error)), FALSE);
@@ -334,10 +344,68 @@ ck_connector_open_session (CkConnector *connector,
+ dbus_message_unref (message);
+ dbus_message_unref (reply);
+ "GetSessionForCookie");
+ dbus_message_append_args (message, DBUS_TYPE_STRING, &connector->cookie,
+ dbus_error_init (&local_error);
+ reply = dbus_connection_send_with_reply_and_block (connector->connection,
+ if (dbus_error_is_set (&local_error)) {
+ "Unable to open session: %s",
+ dbus_error_free (&local_error);
+ dbus_error_init (&local_error);
+ if (! dbus_message_get_args (reply,
+ DBUS_TYPE_OBJECT_PATH, &session_id,
+ if (dbus_error_is_set (&local_error)) {
+ "Unable to open session: %s",
+ dbus_error_free (&local_error);
+ connector->session_id = strdup (session_id);
+ if (connector->session_id == NULL) {
connector->session_created = TRUE;
+ free (connector->cookie);
+ connector->cookie = NULL;
+ free (connector->session_id);
+ connector->session_id = NULL;
dbus_message_unref (reply);
@@ -362,6 +430,7 @@ ck_connector_open_session_with_parameters_valist (CkConnector *connector,
DBusMessageIter iter_array;
_ck_return_val_if_fail (connector != NULL, FALSE);
@@ -470,6 +539,57 @@ ck_connector_open_session_with_parameters_valist (CkConnector *connector,
+ dbus_message_unref (message);
+ dbus_message_unref (reply);
+ "GetSessionForCookie");
+ dbus_message_append_args (message, DBUS_TYPE_STRING, &connector->cookie,
+ dbus_error_init (&local_error);
+ reply = dbus_connection_send_with_reply_and_block (connector->connection,
+ if (dbus_error_is_set (&local_error)) {
+ "Unable to open session: %s",
+ dbus_error_free (&local_error);
+ dbus_error_init (&local_error);
+ if (! dbus_message_get_args (reply,
+ DBUS_TYPE_OBJECT_PATH, &session_id,
+ if (dbus_error_is_set (&local_error)) {
+ "Unable to open session: %s",
+ dbus_error_free (&local_error);
+ connector->session_id = strdup (session_id);
+ if (connector->session_id == NULL) {
connector->session_created = TRUE;
@@ -590,6 +710,73 @@ ck_connector_get_cookie (CkConnector *connector)
+ * Gets the id for the current open session.
+ * Returns #NULL if no session is open.
+ * @returns a constant string with the session id.
+ck_connector_get_session_id (CkConnector *connector)
+ _ck_return_val_if_fail (connector != NULL, NULL);
+ if (! connector->session_created) {
+ return connector->session_id;
+ck_connector_set_remove_on_close (CkConnector *connector,
+ gboolean remove_on_close,
+ const char *ssid = ck_connector_get_session_id (connector);
+ _ck_return_val_if_fail (connector != NULL, FALSE);
+ _ck_return_val_if_fail ((error) == NULL || !dbus_error_is_set ((error)), FALSE);
+ _ck_return_val_if_fail (ssid != NULL, FALSE);
+ if (!connector->session_created || connector->cookie == NULL) {
+ "Unable to close session: %s",
+ if (! dbus_message_append_args (message,
+ DBUS_TYPE_BOOLEAN, &remove_on_close,
+ ret = dbus_connection_send (connector->connection,
+ dbus_message_unref (message);
* Issues the CloseSession method call on the ConsoleKit manager
@@ -56,6 +57,10 @@ dbus_bool_t ck_connector_open_session (CkConnector *ckc,
const char *ck_connector_get_cookie (CkConnector *ckc);
+const char *ck_connector_get_session_id (CkConnector *ckc);
+dbus_bool_t ck_connector_set_remove_on_close (CkConnector *ckc,
+ gboolean remove_on_close,
dbus_bool_t ck_connector_close_session (CkConnector *ckc,
index abedc0b..4a94aab 100644
@@ -51,11 +51,14 @@ static guint32 display_serial = 1;
+ char *x11_display_type;
@@ -66,6 +69,8 @@ struct GdmDisplayPrivate
GdmDisplayAccessFile *access_file;
+ gboolean block_console_session_requests;
GdmSlaveProxy *slave_proxy;
@@ -78,13 +83,18 @@ enum {
+ PROP_BLOCK_CONSOLE_SESSION_REQUESTS,
static void gdm_display_class_init (GdmDisplayClass *klass);
@@ -489,6 +499,20 @@ gdm_display_get_seat_id (GdmDisplay *display,
+gdm_display_get_session_id (GdmDisplay *display,
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ if (session_id != NULL) {
+ *session_id = g_strdup (display->priv->session_id);
finish_idle (GdmDisplay *display)
@@ -550,10 +574,12 @@ gdm_display_real_prepare (GdmDisplay *display)
g_assert (display->priv->slave_proxy == NULL);
- if (!gdm_display_create_authority (display)) {
- g_warning ("Unable to set up access control for display %d",
- display->priv->x11_display_number);
+ if (display->priv->use_auth) {
+ if (!gdm_display_create_authority (display)) {
+ g_warning ("Unable to set up access control for display %d",
+ display->priv->x11_display_number);
_gdm_display_set_status (display, GDM_DISPLAY_PREPARED);
@@ -742,6 +768,20 @@ gdm_display_get_id (GdmDisplay *display,
+gdm_display_get_x11_command (GdmDisplay *display,
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ *command = g_strdup (display->priv->x11_command);
gdm_display_get_x11_display_name (GdmDisplay *display,
@@ -756,6 +796,20 @@ gdm_display_get_x11_display_name (GdmDisplay *display,
+gdm_display_get_x11_display_type (GdmDisplay *display,
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ *type = g_strdup (display->priv->x11_display_type);
gdm_display_is_local (GdmDisplay *display,
@@ -769,6 +823,20 @@ gdm_display_is_local (GdmDisplay *display,
+gdm_display_use_auth (GdmDisplay *display,
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ if (use_auth != NULL) {
+ *use_auth = display->priv->use_auth;
_gdm_display_set_id (GdmDisplay *display,
@@ -778,6 +846,14 @@ _gdm_display_set_id (GdmDisplay *display,
+_gdm_display_set_x11_command (GdmDisplay *display,
+ const char *x11_command)
+ g_free (display->priv->x11_command);
+ display->priv->x11_command = g_strdup (x11_command);
_gdm_display_set_seat_id (GdmDisplay *display,
@@ -786,6 +862,24 @@ _gdm_display_set_seat_id (GdmDisplay *display,
+_gdm_display_set_session_id (GdmDisplay *display,
+ const char *session_id)
+ g_free (display->priv->session_id);
+ display->priv->session_id = g_strdup (session_id);
+gdm_display_set_session_id (GdmDisplay *display,
+ const char *session_id,
+ _gdm_display_set_session_id (display, session_id);
+ g_object_notify (G_OBJECT (display), "session-id");
_gdm_display_set_remote_hostname (GdmDisplay *display,
@@ -809,6 +903,14 @@ _gdm_display_set_x11_display_name (GdmDisplay *display,
+_gdm_display_set_x11_display_type (GdmDisplay *display,
+ const char *display_type)
+ g_free (display->priv->x11_display_type);
+ display->priv->x11_display_type = g_strdup (display_type);
_gdm_display_set_x11_cookie (GdmDisplay *display,
@@ -824,6 +926,13 @@ _gdm_display_set_is_local (GdmDisplay *display,
+_gdm_display_set_use_auth (GdmDisplay *display,
+ display->priv->use_auth = use_auth;
_gdm_display_set_slave_command (GdmDisplay *display,
@@ -832,6 +941,13 @@ _gdm_display_set_slave_command (GdmDisplay *display,
+_gdm_display_set_block_console_session_requests (GdmDisplay *display,
+ gboolean block_console_session_requests)
+ display->priv->block_console_session_requests = block_console_session_requests;
gdm_display_set_property (GObject *object,
@@ -845,12 +961,18 @@ gdm_display_set_property (GObject *object,
_gdm_display_set_id (self, g_value_get_string (value));
+ _gdm_display_set_x11_command (self, g_value_get_string (value));
_gdm_display_set_status (self, g_value_get_int (value));
_gdm_display_set_seat_id (self, g_value_get_string (value));
+ _gdm_display_set_session_id (self, g_value_get_string (value));
case PROP_REMOTE_HOSTNAME:
_gdm_display_set_remote_hostname (self, g_value_get_string (value));
@@ -860,15 +982,24 @@ gdm_display_set_property (GObject *object,
case PROP_X11_DISPLAY_NAME:
_gdm_display_set_x11_display_name (self, g_value_get_string (value));
+ case PROP_X11_DISPLAY_TYPE:
+ _gdm_display_set_x11_display_type (self, g_value_get_string (value));
_gdm_display_set_x11_cookie (self, g_value_get_string (value));
_gdm_display_set_is_local (self, g_value_get_boolean (value));
+ _gdm_display_set_use_auth (self, g_value_get_boolean (value));
_gdm_display_set_slave_command (self, g_value_get_string (value));
+ case PROP_BLOCK_CONSOLE_SESSION_REQUESTS:
+ _gdm_display_set_block_console_session_requests (self, g_value_get_boolean (value));
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -889,12 +1020,18 @@ gdm_display_get_property (GObject *object,
g_value_set_string (value, self->priv->id);
+ g_value_set_string (value, self->priv->x11_command);
g_value_set_int (value, self->priv->status);
g_value_set_string (value, self->priv->seat_id);
+ g_value_set_string (value, self->priv->session_id);
case PROP_REMOTE_HOSTNAME:
g_value_set_string (value, self->priv->remote_hostname);
@@ -904,6 +1041,9 @@ gdm_display_get_property (GObject *object,
case PROP_X11_DISPLAY_NAME:
g_value_set_string (value, self->priv->x11_display_name);
+ case PROP_X11_DISPLAY_TYPE:
+ g_value_set_string (value, self->priv->x11_display_type);
g_value_set_string (value, self->priv->x11_cookie);
@@ -914,9 +1054,15 @@ gdm_display_get_property (GObject *object,
g_value_set_boolean (value, self->priv->is_local);
+ g_value_set_boolean (value, self->priv->use_auth);
g_value_set_string (value, self->priv->slave_command);
+ case PROP_BLOCK_CONSOLE_SESSION_REQUESTS:
+ g_value_set_boolean (value, self->priv->block_console_session_requests);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1033,6 +1179,13 @@ gdm_display_class_init (GdmDisplayClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
+ g_param_spec_string ("x11-command",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
g_param_spec_string ("remote-hostname",
@@ -1056,6 +1209,13 @@ gdm_display_class_init (GdmDisplayClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
+ g_param_spec_string ("x11-display-type",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
g_param_spec_string ("seat-id",
@@ -1063,6 +1223,13 @@ gdm_display_class_init (GdmDisplayClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
+ g_param_spec_string ("session-id",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
g_param_spec_string ("x11-cookie",
@@ -1076,7 +1243,6 @@ gdm_display_class_init (GdmDisplayClass *klass)
g_object_class_install_property (object_class,
g_param_spec_boolean ("is-local",
@@ -1084,7 +1250,13 @@ gdm_display_class_init (GdmDisplayClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ g_param_spec_boolean ("use-auth",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
g_param_spec_string ("slave-command",
@@ -1093,6 +1265,13 @@ gdm_display_class_init (GdmDisplayClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
+ PROP_BLOCK_CONSOLE_SESSION_REQUESTS,
+ g_param_spec_boolean ("block-console-session-requests",
+ "Block Console Session Requests",
+ "Block session requests from ConsoleKit",
+ g_object_class_install_property (object_class,
g_param_spec_int ("status",
@@ -1131,9 +1310,12 @@ gdm_display_finalize (GObject *object)
g_debug ("GdmDisplay: Finalizing display: %s", display->priv->id);
g_free (display->priv->id);
+ g_free (display->priv->x11_command);
g_free (display->priv->seat_id);
+ g_free (display->priv->session_id);
g_free (display->priv->remote_hostname);
g_free (display->priv->x11_display_name);
+ g_free (display->priv->x11_display_type);
g_free (display->priv->x11_cookie);
g_free (display->priv->slave_command);
@@ -1151,3 +1333,25 @@ gdm_display_finalize (GObject *object)
G_OBJECT_CLASS (gdm_display_parent_class)->finalize (object);
+gdm_display_block_console_session_requests (GdmDisplay *display,
+ if (!display->priv->block_console_session_requests) {
+ _gdm_display_set_block_console_session_requests (display, TRUE);
+ g_object_notify (G_OBJECT (display), "block-console-session-requests");
+gdm_display_unblock_console_session_requests (GdmDisplay *display,
+ if (display->priv->block_console_session_requests) {
+ _gdm_display_set_block_console_session_requests (display, FALSE);
+ g_object_notify (G_OBJECT (display), "block-console-session-requests");
@@ -102,6 +102,9 @@ gboolean gdm_display_unmanage (GdmDisplay *disp
gboolean gdm_display_get_id (GdmDisplay *display,
+gboolean gdm_display_get_x11_command (GdmDisplay *display,
gboolean gdm_display_get_remote_hostname (GdmDisplay *display,
@@ -111,12 +114,21 @@ gboolean gdm_display_get_x11_display_number (GdmDisplay *disp
gboolean gdm_display_get_x11_display_name (GdmDisplay *display,
+gboolean gdm_display_get_x11_display_type (GdmDisplay *display,
gboolean gdm_display_get_seat_id (GdmDisplay *display,
+gboolean gdm_display_get_session_id (GdmDisplay *display,
gboolean gdm_display_is_local (GdmDisplay *display,
+gboolean gdm_display_use_auth (GdmDisplay *display,
gboolean gdm_display_get_timed_login_details (GdmDisplay *display,
@@ -130,6 +142,9 @@ gboolean gdm_display_get_x11_cookie (GdmDisplay *disp
gboolean gdm_display_get_x11_authority_file (GdmDisplay *display,
+gboolean gdm_display_set_session_id (GdmDisplay *display,
gboolean gdm_display_add_user_authorization (GdmDisplay *display,
@@ -140,6 +155,11 @@ gboolean gdm_display_remove_user_authorization (GdmDisplay *disp
gboolean gdm_display_set_slave_bus_name (GdmDisplay *display,
+gboolean gdm_display_block_console_session_requests (GdmDisplay *display,
+gboolean gdm_display_unblock_console_session_requests (GdmDisplay *display,
<arg name="id" direction="out" type="o"/>
+ <method name="GetX11Command">
+ <arg name="command" direction="out" type="s"/>
<method name="GetX11DisplayName">
<arg name="name" direction="out" type="s"/>
+ <method name="GetX11DisplayType">
+ <arg name="type" direction="out" type="s"/>
<method name="GetX11DisplayNumber">
- <arg name="name" direction="out" type="i"/>
+ <arg name="number" direction="out" type="i"/>
<method name="GetX11Cookie">
<arg name="x11_cookie" direction="out" type="ay"/>
<arg name="filename" direction="out" type="s"/>
<method name="GetSeatId">
- <arg name="filename" direction="out" type="s"/>
+ <arg name="seat_id" direction="out" type="s"/>
+ <method name="GetSessionId">
+ <arg name="session_id" direction="out" type="s"/>
+ <method name="BlockConsoleSessionRequests">
+ <method name="UnblockConsoleSessionRequests">
<method name="GetRemoteHostname">
<arg name="hostname" direction="out" type="s"/>
<arg name="local" direction="out" type="b"/>
+ <method name="UseAuth">
+ <arg name="use_auth" direction="out" type="b"/>
<method name="AddUserAuthorization">
<arg name="username" direction="in" type="s"/>
<arg name="filename" direction="out" type="s"/>
<method name="RemoveUserAuthorization">
<arg name="username" direction="in" type="s"/>
+ <method name="SetSessionId">
+ <arg name="session_id" direction="in" type="s"/>
<method name="SetSlaveBusName">
<arg name="name" direction="in" type="s"/>
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * Authors: halton.huo@sun.com
+ * Copyright (C) 2009 Sun Microsystems, Inc.
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#define GDM_DYNAMIC_DISPLAY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_DYNAMIC_DISPLAY, GdmDynamicDisplayPrivate))
+struct _GdmDynamicDisplayPrivate
+static void gdm_dynamic_display_class_init (GdmDynamicDisplayClass *klass);
+static void gdm_dynamic_display_init (GdmDynamicDisplay *display);
+static void gdm_dynamic_display_finalize (GObject *object);
+G_DEFINE_TYPE (GdmDynamicDisplay, gdm_dynamic_display, GDM_TYPE_DISPLAY)
+gdm_dynamic_display_create_authority (GdmDisplay *display)
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ GDM_DISPLAY_CLASS (gdm_dynamic_display_parent_class)->create_authority (display);
+gdm_dynamic_display_add_user_authorization (GdmDisplay *display,
+ return GDM_DISPLAY_CLASS (gdm_dynamic_display_parent_class)->add_user_authorization (display, username, filename, error);
+gdm_dynamic_display_remove_user_authorization (GdmDisplay *display,
+ return GDM_DISPLAY_CLASS (gdm_dynamic_display_parent_class)->remove_user_authorization (display, username, error);
+gdm_dynamic_display_manage (GdmDisplay *display)
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ GDM_DISPLAY_CLASS (gdm_dynamic_display_parent_class)->manage (display);
+gdm_dynamic_display_finish (GdmDisplay *display)
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ GDM_DISPLAY_CLASS (gdm_dynamic_display_parent_class)->finish (display);
+ gdm_display_unmanage (display);
+gdm_dynamic_display_unmanage (GdmDisplay *display)
+ g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+ GDM_DISPLAY_CLASS (gdm_dynamic_display_parent_class)->unmanage (display);
+gdm_dynamic_display_set_property (GObject *object,
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+gdm_dynamic_display_get_property (GObject *object,
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+gdm_dynamic_display_class_init (GdmDynamicDisplayClass *klass)
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GdmDisplayClass *display_class = GDM_DISPLAY_CLASS (klass);
+ object_class->get_property = gdm_dynamic_display_get_property;
+ object_class->set_property = gdm_dynamic_display_set_property;
+ object_class->finalize = gdm_dynamic_display_finalize;
+ display_class->create_authority = gdm_dynamic_display_create_authority;
+ display_class->add_user_authorization = gdm_dynamic_display_add_user_authorization;
+ display_class->remove_user_authorization = gdm_dynamic_display_remove_user_authorization;
+ display_class->manage = gdm_dynamic_display_manage;
+ display_class->finish = gdm_dynamic_display_finish;
+ display_class->unmanage = gdm_dynamic_display_unmanage;
+ g_type_class_add_private (klass, sizeof (GdmDynamicDisplayPrivate));
+gdm_dynamic_display_init (GdmDynamicDisplay *display)
+ display->priv = GDM_DYNAMIC_DISPLAY_GET_PRIVATE (display);
+gdm_dynamic_display_finalize (GObject *object)
+ GdmDynamicDisplay *display;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GDM_IS_DYNAMIC_DISPLAY (object));
+ display = GDM_DYNAMIC_DISPLAY (object);
+ g_return_if_fail (display->priv != NULL);
+ G_OBJECT_CLASS (gdm_dynamic_display_parent_class)->finalize (object);
+gdm_dynamic_display_new (int display_number)
+ x11_display = g_strdup_printf (":%d", display_number);
+ object = g_object_new (GDM_TYPE_DYNAMIC_DISPLAY,
+ "x11-display-number", display_number,
+ "x11-display-name", x11_display,
+ return GDM_DISPLAY (object);
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * Authors: halton.huo@sun.com
+ * Copyright (C) 2009 Sun Microsystems, Inc.
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#ifndef __GDM_DYNAMIC_DISPLAY_H
+#define __GDM_DYNAMIC_DISPLAY_H
+#define GDM_TYPE_DYNAMIC_DISPLAY (gdm_dynamic_display_get_type ())
+#define GDM_DYNAMIC_DISPLAY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDM_TYPE_DYNAMIC_DISPLAY, GdmDynamicDisplay))
+#define GDM_DYNAMIC_DISPLAY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_DYNAMIC_DISPLAY, GdmDynamicDisplayClass))
+#define GDM_IS_DYNAMIC_DISPLAY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_DYNAMIC_DISPLAY))
+#define GDM_IS_DYNAMIC_DISPLAY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_DYNAMIC_DISPLAY))
+#define GDM_DYNAMIC_DISPLAY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_DYNAMIC_DISPLAY, GdmDynamicDisplayClass))
+typedef struct _GdmDynamicDisplayPrivate GdmDynamicDisplayPrivate;
+ GdmDynamicDisplayPrivate *priv;
+ GdmDisplayClass parent_class;
+} GdmDynamicDisplayClass;
+GType gdm_dynamic_display_get_type (void);
+GdmDisplay * gdm_dynamic_display_new (int display_number);
+#endif /* __GDM_DYNAMIC_DISPLAY_H */
index 16553e6..076c3af 100644
@@ -481,6 +481,8 @@ run_greeter (GdmFactorySlave *slave)
gboolean display_is_local;
@@ -491,6 +493,8 @@ run_greeter (GdmFactorySlave *slave)
display_is_local = FALSE;
@@ -499,6 +503,8 @@ run_greeter (GdmFactorySlave *slave)
"display-is-local", &display_is_local,
"display-id", &display_id,
"display-name", &display_name,
+ "display-seat-id", &seat_id,
+ "display-session-id", &session_id,
"display-hostname", &display_hostname,
"display-x11-authority-file", &auth_file,
@@ -555,6 +561,8 @@ run_greeter (GdmFactorySlave *slave)
g_debug ("GdmFactorySlave: Creating greeter on %s %s", display_name, display_device);
slave->priv->greeter = gdm_greeter_session_new (display_name,
@@ -584,6 +592,7 @@ run_greeter (GdmFactorySlave *slave)
g_free (display_hostname);
@@ -649,14 +658,12 @@ on_server_died (GdmServer *server,
gdm_factory_slave_run (GdmFactorySlave *slave)
gboolean display_is_local;
+ "display-id", &display_id,
"display-is-local", &display_is_local,
- "display-name", &display_name,
- "display-x11-authority-file", &auth_file,
/* if this is local display start a server if one doesn't
@@ -664,7 +671,7 @@ gdm_factory_slave_run (GdmFactorySlave *slave)
- slave->priv->server = gdm_server_new (display_name, auth_file);
+ slave->priv->server = gdm_server_new (display_id);
g_signal_connect (slave->priv->server,
G_CALLBACK (on_server_exited),
@@ -696,8 +703,7 @@ gdm_factory_slave_run (GdmFactorySlave *slave)
g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
index 994acbc..3dac4f9 100644
@@ -140,6 +140,8 @@ gdm_greeter_session_finalize (GObject *object)
gdm_greeter_session_new (const char *display_name,
+ const char *session_id,
const char *display_device,
const char *display_hostname,
gboolean display_is_local)
@@ -153,6 +155,8 @@ gdm_greeter_session_new (const char *display_name,
"server-env-var-name", "GDM_GREETER_DBUS_ADDRESS",
"register-ck-session", TRUE,
"x11-display-name", display_name,
+ "x11-display-seat-id", seat_id,
+ "x11-display-session-id", session_id,
"x11-display-device", display_device,
"x11-display-hostname", display_hostname,
"x11-display-is-local", display_is_local,
@@ -50,6 +50,8 @@ typedef struct
GType gdm_greeter_session_get_type (void);
GdmGreeterSession * gdm_greeter_session_new (const char *display_name,
+ const char *session_id,
const char *display_device,
const char *display_hostname,
gboolean display_is_local);
index 69daf9e..490e570 100644
#define GDM_LOCAL_DISPLAY_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_LOCAL_DISPLAY_FACTORY, GdmLocalDisplayFactoryPrivate))
#define MAX_DISPLAY_FAILURES 5
+#define IS_STR_SET(x) (x != NULL && x[0] != '\0')
+#define GDM_DBUS_TYPE_G_STRING_STRING_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING))
struct GdmLocalDisplayFactoryPrivate
DBusGConnection *connection;
+ GHashTable *managed_seat_proxies;
/* FIXME: this needs to be per seat? */
@@ -65,7 +81,13 @@ static void gdm_local_display_factory_class_init (GdmLocalDisplayFactoryC
static void gdm_local_display_factory_init (GdmLocalDisplayFactory *factory);
static void gdm_local_display_factory_finalize (GObject *object);
-static GdmDisplay *create_display (GdmLocalDisplayFactory *factory);
+static gboolean create_static_displays (GdmLocalDisplayFactory *factory);
+static void on_display_status_changed (GdmDisplay *display,
+ GdmLocalDisplayFactory *factory);
+static void on_block_console_session_requests_changed (GdmDisplay *display,
+ GdmLocalDisplayFactory *factory);
static gpointer local_display_factory_object = NULL;
@@ -179,6 +201,77 @@ store_display (GdmLocalDisplayFactory *factory,
g_hash_table_insert (factory->priv->displays, GUINT_TO_POINTER (num), NULL);
+store_remove_display (GdmLocalDisplayFactory *factory,
+ GdmDisplayStore *store;
+ store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
+ gdm_display_store_remove (store, display);
+ /* remove from our reserved spot */
+ g_hash_table_remove (factory->priv->displays, GUINT_TO_POINTER (num));
+lookup_by_session (const char *id,
+ char *key1 = user_data;
+ if (!GDM_IS_DISPLAY (display)) {
+ gdm_display_get_session_id (display, &key2, NULL);
+ if (strcmp (key1, key2) == 0) {
+lookup_by_x11_display (const char *id,
+ char *key1 = user_data;
+ if (! GDM_IS_DISPLAY (display)) {
+ gdm_display_get_x11_display_name (display, &key2, NULL);
+ if (strcmp (key1, key2) == 0) {
+factory_find_display (GdmLocalDisplayFactory *factory,
+ GdmDisplayStoreFunc predicate,
+ GdmDisplayStore *store;
+ store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
+ return gdm_display_store_find (store, predicate, user_data);
@@ -275,14 +368,110 @@ gdm_local_display_factory_create_product_display (GdmLocalDisplayFactory *factor
+display_has_pending_sessions (GdmLocalDisplayFactory *factory,
+ return g_object_get_data (G_OBJECT (display),
+ "gdm-local-display-factory-console-session-requests") != NULL;
+manage_next_pending_session_on_display (GdmLocalDisplayFactory *factory,
+ GList *pending_sessions;
+ pending_sessions = g_object_get_data (G_OBJECT (display),
+ "gdm-local-display-factory-console-session-requests");
+ next_session = g_list_last (pending_sessions);
+ if (next_session == NULL) {
+ ssid = next_session->data;
+ pending_sessions = g_list_delete_link (pending_sessions, next_session);
+ g_object_set_data (G_OBJECT (display),
+ "gdm-local-display-factory-console-session-requests",
+ g_object_set (display, "session-id", ssid, NULL);
+ gdm_display_manage (display);
+discard_pending_session_on_display (GdmLocalDisplayFactory *factory,
+ GList *pending_sessions;
+ pending_sessions = g_object_get_data (G_OBJECT (display),
+ "gdm-local-display-factory-console-session-requests");
+ node = g_list_last (pending_sessions);
+ prev_node = node->prev;
+ node_ssid = node->data;
+ if (strcmp (node_ssid, ssid) == 0) {
+ pending_sessions = g_list_delete_link (pending_sessions, node);
+ g_object_set_data (G_OBJECT (display),
+ "gdm-local-display-factory-console-session-requests",
-on_static_display_status_changed (GdmDisplay *display,
- GdmLocalDisplayFactory *factory)
+on_block_console_session_requests_changed (GdmDisplay *display,
+ GdmLocalDisplayFactory *factory)
+ gboolean display_is_blocked;
+ g_object_get (G_OBJECT (display),
+ "block-console-session-requests",
+ &display_is_blocked, NULL);
+ if (display_is_blocked) {
+ gdm_display_get_x11_display_number (display, &number, NULL);
+ g_debug ("GdmLocalDisplayFactory: display :%d is blocked", number);
+ if (status == GDM_DISPLAY_UNMANAGED) {
+ manage_next_pending_session_on_display (factory, display);
+on_display_status_changed (GdmDisplay *display,
+ GdmLocalDisplayFactory *factory)
+ gboolean display_is_blocked;
gdm_display_get_x11_display_number (display, &num, NULL);
@@ -292,16 +481,17 @@ on_static_display_status_changed (GdmDisplay *display,
status = gdm_display_get_status (display);
+ g_object_get (G_OBJECT (display),
+ "block-console-session-requests",
+ &display_is_blocked, NULL);
g_debug ("GdmLocalDisplayFactory: static display status changed: %d", status);
case GDM_DISPLAY_FINISHED:
- /* remove the display number from factory->priv->displays
- so that it may be reused */
- g_hash_table_remove (factory->priv->displays, GUINT_TO_POINTER (num));
- gdm_display_store_remove (store, display);
- /* reset num failures */
+ /* Do not remove the display number from factory->priv->displays
+ here because it should be remove under signal "SessionRemoved"
factory->priv->num_failures = 0;
- create_display (factory);
/* leave the display number in factory->priv->displays
@@ -313,10 +503,12 @@ on_static_display_status_changed (GdmDisplay *display,
g_warning ("GdmLocalDisplayFactory: maximum number of X display failures reached: check X server log for errors");
- create_display (factory);
case GDM_DISPLAY_UNMANAGED:
+ if (display_has_pending_sessions (factory, display) && !display_is_blocked) {
+ store_display (factory, num, display);
+ manage_next_pending_session_on_display (factory, display);
case GDM_DISPLAY_PREPARED:
@@ -328,42 +520,493 @@ on_static_display_status_changed (GdmDisplay *display,
-create_display (GdmLocalDisplayFactory *factory)
+strrep (char* in, char** out, char* old, char* new)
+ char* orig = strdup(in);
+ char* found = strstr(orig, old);
+ *out = malloc(strlen(orig) + 1);
+ int idx = found - orig;
+ *out = realloc(*out, strlen(orig) - strlen(old) + strlen(new) + 1);
+ strncpy(*out, orig, idx);
+ strcpy(*out + idx, new);
+ strcpy(*out + idx + strlen(new), orig + idx + strlen(old));
+ temp = malloc(idx+strlen(new)+1);
+ strncpy(temp,*out,idx+strlen(new));
+ temp[idx + strlen(new)] = '\0';
+ strrep(found + strlen(old), out, old, new);
+ temp = realloc(temp, strlen(temp) + strlen(*out) + 1);
+seat_open_session_request (DBusGProxy *seat_proxy,
+ const char *session_type,
+ const char *display_template_name,
+ GHashTable *display_variables,
+ const char *display_type,
+ GHashTable *parameters,
+ GdmLocalDisplayFactory *factory)
+ const char *sid = NULL;
+ gboolean display_is_blocked;
+ GList *pending_sessions;
+ g_return_if_fail (GDM_IS_LOCAL_DISPLAY_FACTORY (factory));
+ display_is_blocked = FALSE;
+ display = factory_find_display (factory, lookup_by_session, (gpointer)ssid);
+ g_object_get (G_OBJECT (display),
+ "block-console-session-requests",
+ &display_is_blocked, NULL);
- num = take_next_display_number (factory);
+ if (strcmp (display_type, "X11") != 0) {
+ g_warning ("Unknown display type '%s' requested", display_type);
+ xserver_command = g_hash_table_lookup (parameters, "Exec");
+ if (! g_shell_parse_argv (xserver_command, &argc, &argv, &error)) {
+ g_warning ("Could not parse command %s: %s", xserver_command, error->message);
+ comm = g_strdup (xserver_command);
+ for (i = 0; i < argc; i++) {
+ /* replase $display in case of not specified */
+ if (g_str_equal (argv[i], "$display")) {
+ display_number = take_next_display_number (factory);
+ strrep (comm, &comm, "$display", "");
+ /* get display_number in case of specified */
+ if (g_str_has_prefix (argv[i], ":")) {
+ display_number = atoi (argv[i]+1);
+ strrep (comm, &comm, argv[i], "");
+ if (strstr (comm, "-indirect")) {
+ if (strstr (comm, "-auth $auth")) {
+ strrep (comm, &comm, "-auth $auth", "");
+ if (strstr (comm, "$vt")) {
+ strrep (comm, &comm, "$vt", "");
+ /* TODO: Start a xdmcp chooser as request */
+ /* display = gdm_xdmcp_chooser_display_new (display_number); */
+ display = gdm_dynamic_display_new (display_number);
+ g_warning ("Unable to create display: %d", display_number);
+ g_object_set (display, "session-id", ssid, NULL);
+ sid = dbus_g_proxy_get_path (seat_proxy);
+ g_object_set (display, "seat-id", sid, NULL);
+ g_object_set (display, "x11-command", comm, NULL);
+ if (IS_STR_SET (display_template_name))
+ g_object_set (display, "x11-display-type", display_template_name, NULL);
+ g_object_set (display, "use-auth", use_auth, NULL);
+ g_signal_connect (display,
+ G_CALLBACK (on_display_status_changed),
+ g_signal_connect (display,
+ "notify::block-console-session-requests",
+ G_CALLBACK (on_block_console_session_requests_changed),
+ store_display (factory, display_number, display);
+ g_object_unref (display);
+ if (! gdm_display_manage (display)) {
+ gdm_display_unmanage (display);
+ /* FIXME: Make sure the display returned is compatible
+ if (!display_is_blocked) {
+ /* FIXME: What do we do here?
+ g_warning ("Got console request to add display for session that "
+ "already has a display, and display is already in "
+ pending_sessions = g_object_get_data (G_OBJECT (display),
+ "gdm-local-display-factory-console-session-requests");
+ pending_sessions = g_list_prepend (pending_sessions, g_strdup (ssid));
+ g_object_set_data (G_OBJECT (display),
+ "gdm-local-display-factory-console-session-requests",
+seat_close_session_request (DBusGProxy *seat_proxy,
+ GdmLocalDisplayFactory *factory)
+ g_return_if_fail (GDM_IS_LOCAL_DISPLAY_FACTORY (factory));
+ display = factory_find_display (factory, lookup_by_session, (gpointer)ssid);
- display = gdm_static_factory_display_new (num);
- display = gdm_static_display_new (num);
- g_warning ("Unable to create display: %d", num);
+ g_debug ("GdmLocalDisplayFactory: display for session '%s' doesn't exists", ssid);
- /* FIXME: don't hardcode seat1? */
- g_object_set (display, "seat-id", CK_SEAT1_PATH, NULL);
+ g_object_get (G_OBJECT (display), "session-id", &display_ssid, NULL);
- g_signal_connect (display,
- G_CALLBACK (on_static_display_status_changed),
+ if (display_ssid == NULL || strcmp (ssid, display_ssid) != 0) {
+ discard_pending_session_on_display (factory, display, ssid);
- store_display (factory, num, display);
+ if (! gdm_display_unmanage (display)) {
- /* let store own the ref */
- g_object_unref (display);
+ gdm_display_get_x11_display_number (display, &display_number, NULL);
+ store_remove_display (factory, display_number, display);
- if (! gdm_display_manage (display)) {
- gdm_display_unmanage (display);
+get_session_x11_display (GdmLocalDisplayFactory *factory,
+ proxy = dbus_g_proxy_new_for_name (factory->priv->connection,
+ res = dbus_g_proxy_call (proxy,
+ G_TYPE_STRING, x11_display,
+seat_session_added (DBusGProxy *seat_proxy,
+ GdmLocalDisplayFactory *factory)
+ res = get_session_x11_display (factory, ssid, &x11_display);
+ g_warning ("Failed to get X11 display number for %s", ssid);
+ display = factory_find_display (factory, lookup_by_x11_display,
+ gdm_display_set_session_id (display, ssid, NULL);
+ g_debug ("Update session id for display %s to %s",
+seat_session_removed (DBusGProxy *seat_proxy,
+ GdmLocalDisplayFactory *factory)
+ GdmDisplay *display = NULL;
+ display = factory_find_display (factory, lookup_by_session,
+ gdm_display_get_x11_display_number (display, &num, NULL);
+ store_remove_display (factory, num, display);
+seat_remove_request (DBusGProxy *seat_proxy,
+ GdmLocalDisplayFactory *factory)
+ const char *sid_to_remove;
+ GQueue ssids_to_remove;
+ sid_to_remove = dbus_g_proxy_get_path (seat_proxy);
+ g_queue_init (&ssids_to_remove);
+ g_hash_table_iter_init (&iter, factory->priv->displays);
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ gdm_display_get_seat_id (display, &sid, NULL);
+ if (strcmp (sid, sid_to_remove) == 0) {
+ gdm_display_get_session_id (display, &ssid, NULL);
+ g_queue_push_tail (&ssids_to_remove, ssid);
+ while (!g_queue_is_empty (&ssids_to_remove)) {
+ ssid = g_queue_pop_head (&ssids_to_remove);
+ seat_close_session_request (seat_proxy, ssid, factory);
+ g_hash_table_remove (factory->priv->managed_seat_proxies, sid_to_remove);
+ dbus_g_proxy_call_no_reply (seat_proxy,
+ dbus_g_proxy_call_no_reply (factory->priv->proxy_ck,
+ DBUS_TYPE_G_OBJECT_PATH, sid_to_remove,
+manage_static_sessions_per_seat (GdmLocalDisplayFactory *factory,
+ proxy = dbus_g_proxy_new_for_name (factory->priv->connection,
+ g_warning ("Failed to connect to the ConsoleKit seat object");
+ dbus_g_object_register_marshaller (gdm_marshal_VOID__STRING_STRING_STRING_POINTER_STRING_POINTER,
+ DBUS_TYPE_G_OBJECT_PATH,
+ GDM_DBUS_TYPE_G_STRING_STRING_HASHTABLE,
+ GDM_DBUS_TYPE_G_STRING_STRING_HASHTABLE,
+ dbus_g_proxy_add_signal (proxy,
+ DBUS_TYPE_G_OBJECT_PATH,
+ GDM_DBUS_TYPE_G_STRING_STRING_HASHTABLE,
+ GDM_DBUS_TYPE_G_STRING_STRING_HASHTABLE,
+ dbus_g_proxy_add_signal (proxy,
+ DBUS_TYPE_G_OBJECT_PATH,
+ dbus_g_proxy_add_signal (proxy,
+ DBUS_TYPE_G_OBJECT_PATH,
+ dbus_g_proxy_add_signal (proxy,
+ DBUS_TYPE_G_OBJECT_PATH,
+ dbus_g_proxy_add_signal (proxy,
+ dbus_g_proxy_connect_signal (proxy,
+ G_CALLBACK (seat_open_session_request),
+ dbus_g_proxy_connect_signal (proxy,
+ G_CALLBACK (seat_close_session_request),
+ dbus_g_proxy_connect_signal (proxy,
+ G_CALLBACK (seat_session_added),
+ dbus_g_proxy_connect_signal (proxy,
+ G_CALLBACK (seat_session_removed),
+ dbus_g_proxy_connect_signal (proxy,
+ G_CALLBACK (seat_remove_request),
+ dbus_g_proxy_call_no_reply (proxy,
+ g_hash_table_insert (factory->priv->managed_seat_proxies,
+ g_strdup (dbus_g_proxy_get_path (proxy)),
+seat_added (DBusGProxy *mgr_proxy,
+ GdmLocalDisplayFactory *factory)
+ if (strcmp (type, "Default") == 0) {
+ manage_static_sessions_per_seat (factory, sid);
+create_static_displays (GdmLocalDisplayFactory *factory)
+ res = dbus_g_proxy_call (factory->priv->proxy_ck,
+ dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
+ g_warning ("Failed to get list of unmanaged seats: %s", error->message);
+ for (i = 0; i < seats->len; i++) {
+ sid = g_ptr_array_index (seats, i);
+ manage_static_sessions_per_seat (factory, sid);
@@ -380,7 +1023,7 @@ gdm_local_display_factory_start (GdmDisplayFactory *base_factory)
create_displays_for_pci_devices (factory);
- create_display (factory);
+ create_static_displays (factory);
@@ -442,6 +1085,47 @@ register_factory (GdmLocalDisplayFactory *factory)
+connect_to_ck (GdmLocalDisplayFactory *factory)
+ GdmLocalDisplayFactoryPrivate *priv;
+ priv->proxy_ck = dbus_g_proxy_new_for_name (priv->connection,
+ if (priv->proxy_ck == NULL) {
+ g_warning ("Couldn't create proxy for ConsoleKit Manager");
+ dbus_g_object_register_marshaller (gdm_marshal_VOID__STRING_STRING,
+ G_TYPE_STRING, G_TYPE_STRING,
+ dbus_g_proxy_add_signal (priv->proxy_ck,
+ dbus_g_proxy_connect_signal (priv->proxy_ck,
+ G_CALLBACK (seat_added),
+disconnect_from_ck (GdmLocalDisplayFactory *factory)
+ if (factory->priv->proxy_ck == NULL) {
+ g_object_unref (factory->priv->proxy_ck);
gdm_local_display_factory_constructor (GType type,
guint n_construct_properties,
@@ -459,6 +1143,8 @@ gdm_local_display_factory_constructor (GType type,
g_warning ("Unable to register local display factory with system bus");
+ connect_to_ck (factory);
return G_OBJECT (factory);
@@ -487,6 +1173,10 @@ gdm_local_display_factory_init (GdmLocalDisplayFactory *factory)
factory->priv = GDM_LOCAL_DISPLAY_FACTORY_GET_PRIVATE (factory);
factory->priv->displays = g_hash_table_new (NULL, NULL);
+ factory->priv->managed_seat_proxies = g_hash_table_new_full (g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_object_unref);
@@ -502,6 +1192,9 @@ gdm_local_display_factory_finalize (GObject *object)
g_return_if_fail (factory->priv != NULL);
g_hash_table_destroy (factory->priv->displays);
+ g_hash_table_destroy (factory->priv->managed_seat_proxies);
+ disconnect_from_ck (factory);
G_OBJECT_CLASS (gdm_local_display_factory_parent_class)->finalize (object);
@@ -415,14 +415,12 @@ on_server_died (GdmServer *server,
gdm_product_slave_create_server (GdmProductSlave *slave)
gboolean display_is_local;
+ "display-id", &display_id,
"display-is-local", &display_is_local,
- "display-name", &display_name,
- "display-x11-authority-file", &auth_file,
/* if this is local display start a server if one doesn't
@@ -430,7 +428,7 @@ gdm_product_slave_create_server (GdmProductSlave *slave)
- slave->priv->server = gdm_server_new (display_name, auth_file);
+ slave->priv->server = gdm_server_new (display_id);
g_signal_connect (slave->priv->server,
G_CALLBACK (on_server_exited),
@@ -462,8 +460,7 @@ gdm_product_slave_create_server (GdmProductSlave *slave)
g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
@@ -50,6 +52,9 @@ extern char **environ;
#define GDM_SERVER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SERVER, GdmServerPrivate))
/* These are the servstat values, also used as server
#define SERVER_TIMEOUT 2 /* Server didn't start */
@@ -65,12 +70,12 @@ struct GdmServerPrivate
@@ -97,7 +102,7 @@ enum {
@@ -303,11 +308,6 @@ gdm_server_resolve_command_line (GdmServer *server,
- if (server->priv->disable_tcp && ! query_in_arglist) {
- argv[len++] = g_strdup ("-nolisten");
- argv[len++] = g_strdup ("tcp");
if (vtarg != NULL && ! gotvtarg) {
argv[len++] = g_strdup (vtarg);
@@ -602,6 +602,7 @@ gdm_server_spawn (GdmServer *server,
@@ -624,6 +625,29 @@ gdm_server_spawn (GdmServer *server,
+ /* Sometimes quit X slowly, adding this to avoid restart session
+ if ((tmp = strstr (server->priv->display_name, ":")) != NULL) {
+ display_num = g_ascii_strtod (tmp, &p);
+ socket_file = g_strdup_printf ("/tmp/.X11-unix/X%d",
+ if (!g_file_test (socket_file, G_FILE_TEST_EXISTS))
env = get_server_environment (server);
freeme = g_strjoinv (" ", argv);
@@ -733,13 +757,12 @@ gdm_server_stop (GdmServer *server)
-_gdm_server_set_display_name (GdmServer *server,
+_gdm_server_set_display_id (GdmServer *server,
- g_free (server->priv->display_name);
- server->priv->display_name = g_strdup (name);
+ g_free (server->priv->display_id);
+ server->priv->display_id = g_strdup (id);
@@ -759,13 +782,6 @@ _gdm_server_set_user_name (GdmServer *server,
-_gdm_server_set_disable_tcp (GdmServer *server,
- server->priv->disable_tcp = disabled;
gdm_server_set_property (GObject *object,
@@ -776,8 +792,8 @@ gdm_server_set_property (GObject *object,
self = GDM_SERVER (object);
- case PROP_DISPLAY_NAME:
- _gdm_server_set_display_name (self, g_value_get_string (value));
+ _gdm_server_set_display_id (self, g_value_get_string (value));
_gdm_server_set_auth_file (self, g_value_get_string (value));
@@ -785,9 +801,6 @@ gdm_server_set_property (GObject *object,
_gdm_server_set_user_name (self, g_value_get_string (value));
- _gdm_server_set_disable_tcp (self, g_value_get_boolean (value));
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -805,8 +818,8 @@ gdm_server_get_property (GObject *object,
self = GDM_SERVER (object);
- case PROP_DISPLAY_NAME:
- g_value_set_string (value, self->priv->display_name);
+ g_value_set_string (value, self->priv->display_id);
case PROP_DISPLAY_DEVICE:
g_value_take_string (value,
@@ -818,9 +831,6 @@ gdm_server_get_property (GObject *object,
g_value_set_string (value, self->priv->user_name);
- g_value_set_boolean (value, self->priv->disable_tcp);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -886,10 +896,10 @@ gdm_server_class_init (GdmServerClass *klass)
g_object_class_install_property (object_class,
- g_param_spec_string ("display-name",
+ g_param_spec_string ("display-id",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
@@ -914,13 +924,6 @@ gdm_server_class_init (GdmServerClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class,
- g_param_spec_boolean ("disable-tcp",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
@@ -931,7 +934,7 @@ gdm_server_init (GdmServer *server)
server->priv = GDM_SERVER_GET_PRIVATE (server);
- server->priv->command = g_strdup (X_SERVER " -br -verbose");
+ server->priv->command = NULL;
server->priv->log_dir = g_strdup (LOGDIR);
add_ready_handler (server);
@@ -953,19 +956,129 @@ gdm_server_finalize (GObject *object)
gdm_server_stop (server);
+ g_free (server->priv->command);
+ g_free (server->priv->log_dir);
G_OBJECT_CLASS (gdm_server_parent_class)->finalize (object);
-gdm_server_new (const char *display_name,
+gdm_server_new (const char *display_id)
+ DBusGConnection *connection;
object = g_object_new (GDM_TYPE_SERVER,
- "display-name", display_name,
- "auth-file", auth_file,
+ "display-id", display_id,
- return GDM_SERVER (object);
+ server = GDM_SERVER (object);
+ server->priv->pid = -1;
+ server->priv->log_dir = g_strdup (LOGDIR);
+ g_assert (server->priv->display_id != NULL);
+ connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (connection == NULL) {
+ g_critical ("error getting system bus: %s", error->message);
+ g_debug ("GdmServer: Creating proxy for %s", server->priv->display_id);
+ proxy = dbus_g_proxy_new_for_name_owner (connection,
+ server->priv->display_id,
+ GDM_DBUS_DISPLAY_INTERFACE,
+ g_warning ("Failed to create display proxy %s: %s", server->priv->display_id, error->message);
+ g_warning ("Unable to create display proxy");
+ /* cache some values up front */
+ res = dbus_g_proxy_call (proxy,
+ G_TYPE_STRING, &server->priv->display_name,
+ g_warning ("Failed to get value: %s", error->message);
+ g_warning ("Failed to get value");
+ /* If display_name is not set, quit */
+ if (! server->priv->display_name || (strlen (server->priv->display_name) == 0)) {
+ g_warning ("Wrong value of method GetX11DisplayName for %s",server->priv->display_id);
+ res = dbus_g_proxy_call (proxy,
+ G_TYPE_STRING, &server->priv->command,
+ g_warning ("Failed to get value: %s", error->message);
+ g_warning ("Failed to get value");
+ res = dbus_g_proxy_call (proxy,
+ G_TYPE_STRING, &server->priv->auth_file,
+ g_warning ("Failed to get value: %s", error->message);
+ g_warning ("Failed to get value");
+ /* If auth_file is not set, set it NULL */
+ if (server->priv->auth_file && (strlen (server->priv->auth_file) == 0)) {
+ g_free (server->priv->auth_file);
+ server->priv->auth_file = NULL;
index 535a69a..84feb1f 100644
@@ -53,8 +53,7 @@ typedef struct
GType gdm_server_get_type (void);
-GdmServer * gdm_server_new (const char *display_id,
- const char *auth_file);
+GdmServer * gdm_server_new (const char *display_id);
gboolean gdm_server_start (GdmServer *server);
gboolean gdm_server_stop (GdmServer *server);
char * gdm_server_get_display_device (GdmServer *server);
@@ -92,11 +94,15 @@ struct _GdmSessionDirectPrivate
char *display_x11_authority_file;
+ char *display_console_session;
gboolean display_is_local;
+ DBusGProxy *display_proxy;
DBusGConnection *connection;
@@ -108,7 +114,10 @@ enum {
PROP_DISPLAY_X11_AUTHORITY_FILE,
+ PROP_DISPLAY_CONSOLE_SESSION,
PROP_USER_X11_AUTHORITY_FILE,
static void gdm_session_iface_init (GdmSessionIface *iface);
@@ -787,6 +796,34 @@ gdm_session_direct_handle_username_changed (GdmSessionDirect *session,
return DBUS_HANDLER_RESULT_HANDLED;
+static DBusHandlerResult
+gdm_session_direct_handle_display_console_session_updated (GdmSessionDirect *session,
+ DBusConnection *connection,
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &text,
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
+ g_debug ("GdmSessionDirect: changing ck session id to '%s'",
+ return DBUS_HANDLER_RESULT_HANDLED;
cancel_pending_query (GdmSessionDirect *session)
@@ -1269,6 +1306,8 @@ session_worker_message (DBusConnection *connection,
return gdm_session_direct_handle_accreditation_failed (session, connection, message);
} else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "UsernameChanged")) {
return gdm_session_direct_handle_username_changed (session, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "DisplayConsoleSessionUpdated")) {
+ return gdm_session_direct_handle_display_console_session_updated (session, connection, message);
} else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "SessionOpened")) {
return gdm_session_direct_handle_session_opened (session, connection, message);
} else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "OpenFailed")) {
@@ -1377,6 +1416,8 @@ do_introspect (DBusConnection *connection,
" <signal name=\"Setup\">\n"
" <arg name=\"service_name\" type=\"s\"/>\n"
" <arg name=\"x11_display_name\" type=\"s\"/>\n"
+ " <arg name=\"x11_display_type\" type=\"s\"/>\n"
+ " <arg name=\"x11_display_seat_id\" type=\"s\"/>\n"
" <arg name=\"display_device\" type=\"s\"/>\n"
" <arg name=\"hostname\" type=\"s\"/>\n"
" <arg name=\"x11_authority_file\" type=\"s\"/>\n"
@@ -1384,6 +1425,8 @@ do_introspect (DBusConnection *connection,
" <signal name=\"SetupForUser\">\n"
" <arg name=\"service_name\" type=\"s\"/>\n"
" <arg name=\"x11_display_name\" type=\"s\"/>\n"
+ " <arg name=\"x11_display_type\" type=\"s\"/>\n"
+ " <arg name=\"x11_seat_id\" type=\"s\"/>\n"
" <arg name=\"display_device\" type=\"s\"/>\n"
" <arg name=\"hostname\" type=\"s\"/>\n"
" <arg name=\"x11_authority_file\" type=\"s\"/>\n"
@@ -1748,6 +1791,8 @@ send_setup (GdmSessionDirect *session,
const char *display_name;
+ const char *display_type;
+ const char *display_seat_id;
const char *display_device;
const char *display_hostname;
const char *display_x11_authority_file;
@@ -1759,6 +1804,16 @@ send_setup (GdmSessionDirect *session,
+ if (session->priv->display_type != NULL) {
+ display_type = session->priv->display_type;
+ if (session->priv->display_seat_id!= NULL) {
+ display_seat_id = session->priv->display_seat_id;
if (session->priv->display_hostname != NULL) {
display_hostname = session->priv->display_hostname;
@@ -1784,6 +1839,8 @@ send_setup (GdmSessionDirect *session,
dbus_message_iter_init_append (message, &iter);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &service_name);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_name);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_type);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_seat_id);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_device);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_hostname);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_x11_authority_file);
@@ -1802,6 +1859,8 @@ send_setup_for_user (GdmSessionDirect *session,
const char *display_name;
+ const char *display_type;
+ const char *display_seat_id;
const char *display_device;
const char *display_hostname;
const char *display_x11_authority_file;
@@ -1814,6 +1873,16 @@ send_setup_for_user (GdmSessionDirect *session,
+ if (session->priv->display_type != NULL) {
+ display_type = session->priv->display_type;
+ if (session->priv->display_seat_id != NULL) {
+ display_seat_id = session->priv->display_seat_id;
if (session->priv->display_hostname != NULL) {
display_hostname = session->priv->display_hostname;
@@ -1844,6 +1913,8 @@ send_setup_for_user (GdmSessionDirect *session,
dbus_message_iter_init_append (message, &iter);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &service_name);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_name);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_type);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_seat_id);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_device);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_hostname);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_x11_authority_file);
@@ -2353,6 +2424,30 @@ _gdm_session_direct_set_display_x11_authority_file (GdmSessionDirect *session,
+_gdm_session_direct_set_display_type (GdmSessionDirect *session,
+ g_free (session->priv->display_type);
+ session->priv->display_type = g_strdup (type);
+_gdm_session_direct_set_display_seat_id (GdmSessionDirect *session,
+ g_free (session->priv->display_seat_id);
+ session->priv->display_seat_id = g_strdup (sid);
+_gdm_session_direct_set_display_console_session (GdmSessionDirect *session,
+ const char *console_session)
+ g_free (session->priv->display_console_session);
+ session->priv->display_console_session = g_strdup (console_session);
_gdm_session_direct_set_display_is_local (GdmSessionDirect *session,
@@ -2388,9 +2483,18 @@ gdm_session_direct_set_property (GObject *object,
case PROP_DISPLAY_X11_AUTHORITY_FILE:
_gdm_session_direct_set_display_x11_authority_file (self, g_value_get_string (value));
+ case PROP_DISPLAY_CONSOLE_SESSION:
+ _gdm_session_direct_set_display_console_session (self, g_value_get_string (value));
case PROP_DISPLAY_IS_LOCAL:
_gdm_session_direct_set_display_is_local (self, g_value_get_boolean (value));
+ case PROP_DISPLAY_TYPE:
+ _gdm_session_direct_set_display_type (self, g_value_get_string (value));
+ case PROP_DISPLAY_SEAT_ID:
+ _gdm_session_direct_set_display_seat_id (self, g_value_get_string (value));
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -2426,9 +2530,18 @@ gdm_session_direct_get_property (GObject *object,
case PROP_DISPLAY_X11_AUTHORITY_FILE:
g_value_set_string (value, self->priv->display_x11_authority_file);
+ case PROP_DISPLAY_CONSOLE_SESSION:
+ g_value_set_string (value, self->priv->display_console_session);
case PROP_DISPLAY_IS_LOCAL:
g_value_set_boolean (value, self->priv->display_is_local);
+ case PROP_DISPLAY_TYPE:
+ g_value_set_string (value, self->priv->display_type);
+ case PROP_DISPLAY_SEAT_ID:
+ g_value_set_string (value, self->priv->display_seat_id);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -2464,6 +2577,12 @@ gdm_session_direct_dispose (GObject *object)
g_free (session->priv->server_address);
session->priv->server_address = NULL;
+ g_free (session->priv->display_type);
+ session->priv->display_type = NULL;
+ g_free (session->priv->display_seat_id);
+ session->priv->display_seat_id = NULL;
if (session->priv->server != NULL) {
dbus_server_disconnect (session->priv->server);
dbus_server_unref (session->priv->server);
@@ -2475,6 +2594,11 @@ gdm_session_direct_dispose (GObject *object)
session->priv->environment = NULL;
+ if (session->priv->display_proxy != NULL) {
+ g_object_unref (session->priv->display_proxy);
G_OBJECT_CLASS (gdm_session_direct_parent_class)->dispose (object);
@@ -2625,6 +2749,14 @@ gdm_session_direct_class_init (GdmSessionDirectClass *session_class)
"display x11 authority file",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_DISPLAY_CONSOLE_SESSION,
+ g_param_spec_string ("display-console-session",
+ "Display ConsoleKit session",
+ "The ConsoleKit Session Id for the display",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_USER_X11_AUTHORITY_FILE,
@@ -2640,11 +2772,140 @@ gdm_session_direct_class_init (GdmSessionDirectClass *session_class)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ g_param_spec_string ("display-type",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ g_param_spec_string ("seat-id",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
dbus_g_object_type_install_info (GDM_TYPE_SESSION_DIRECT, &dbus_glib_gdm_session_direct_object_info);
+display_proxy_destroyed_cb (DBusGProxy *display_proxy,
+ GdmSessionDirect *session)
+ g_debug ("GdmSessionDirect: Disconnected from display");
+ session->priv->display_proxy = NULL;
+init_display_data (GdmSessionDirect *session)
+ g_assert (session->priv->display_proxy == NULL);
+ session->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (session->priv->connection == NULL) {
+ g_critical ("error getting system bus: %s", error->message);
+ session->priv->display_proxy = dbus_g_proxy_new_for_name_owner (
+ session->priv->connection,
+ session->priv->display_id,
+ GDM_DBUS_DISPLAY_INTERFACE,
+ g_signal_connect (session->priv->display_proxy,
+ G_CALLBACK (display_proxy_destroyed_cb),
+ if (session->priv->display_proxy == NULL) {
+ g_warning ("Failed to create display proxy %s: %s", session->priv->display_id, error->message);
+ g_warning ("Unable to create display proxy");
+ /* Make sure display ID works */
+ res = dbus_g_proxy_call (session->priv->display_proxy,
+ DBUS_TYPE_G_OBJECT_PATH, &id,
+ g_warning ("Failed to get display id %s: %s", session->priv->display_id, error->message);
+ g_warning ("Failed to get display id %s", session->priv->display_id);
+ if (strcmp (id, session->priv->display_id) != 0) {
+ g_critical ("Display ID doesn't match");
+ res = dbus_g_proxy_call (session->priv->display_proxy,
+ G_TYPE_STRING, &session->priv->display_type,
+ g_warning ("Failed to get value: %s", error->message);
+ g_warning ("Failed to get value");
+ res = dbus_g_proxy_call (session->priv->display_proxy,
+ G_TYPE_STRING, &session->priv->display_seat_id,
+ g_warning ("Failed to get value: %s", error->message);
+ g_warning ("Failed to get value");
gdm_session_direct_new (const char *display_id,
const char *display_name,
@@ -2664,6 +2925,8 @@ gdm_session_direct_new (const char *display_id,
"display-is-local", display_is_local,
+ init_display_data (session);
index ec1d5b0..4d42227 100644
@@ -117,6 +117,8 @@ struct GdmSessionWorkerPrivate
+ char *x11_display_type;
char *x11_authority_file;
@@ -177,6 +179,8 @@ open_ck_session (GdmSessionWorker *worker)
const char *display_name;
+ const char *display_type;
const char *display_device;
const char *display_hostname;
@@ -188,6 +192,16 @@ open_ck_session (GdmSessionWorker *worker)
+ if (worker->priv->x11_display_type != NULL) {
+ display_type = worker->priv->x11_display_type;
+ if (worker->priv->seat_id != NULL) {
+ seat_id = worker->priv->seat_id;
if (worker->priv->hostname != NULL) {
display_hostname = worker->priv->hostname;
@@ -224,6 +238,8 @@ open_ck_session (GdmSessionWorker *worker)
dbus_error_init (&error);
res = ck_connector_open_session_with_parameters (worker->priv->ckc,
+ "display-type", &display_type,
"unix-user", &pwent->pw_uid,
"x11-display", &display_name,
"x11-display-device", &display_device,
@@ -1792,6 +1808,7 @@ static void
register_ck_session (GdmSessionWorker *worker)
const char *session_cookie;
+ const char *session_id;
@@ -1804,6 +1821,12 @@ register_ck_session (GdmSessionWorker *worker)
+ session_id = ck_connector_get_session_id (worker->priv->ckc);
+ send_dbus_string_method (worker->priv->connection,
+ "DisplayConsoleSessionUpdated",
@@ -1823,19 +1846,24 @@ session_worker_child_watch (GPid pid,
if (WIFEXITED (status)) {
int code = WEXITSTATUS (status);
+ ck_connector_set_remove_on_close (worker->priv->ckc,
send_dbus_int_method (worker->priv->connection,
} else if (WIFSIGNALED (status)) {
int num = WTERMSIG (status);
+ ck_connector_set_remove_on_close (worker->priv->ckc,
send_dbus_int_method (worker->priv->connection,
if (worker->priv->ckc != NULL) {
- ck_connector_close_session (worker->priv->ckc, NULL);
ck_connector_unref (worker->priv->ckc);
worker->priv->ckc = NULL;
@@ -2616,6 +2644,8 @@ on_setup (GdmSessionWorker *worker,
const char *x11_display_name;
+ const char *x11_display_type;
const char *x11_authority_file;
@@ -2631,6 +2661,8 @@ on_setup (GdmSessionWorker *worker,
DBUS_TYPE_STRING, &service,
DBUS_TYPE_STRING, &x11_display_name,
+ DBUS_TYPE_STRING, &x11_display_type,
+ DBUS_TYPE_STRING, &seat_id,
DBUS_TYPE_STRING, &console,
DBUS_TYPE_STRING, &hostname,
DBUS_TYPE_STRING, &x11_authority_file,
@@ -2638,6 +2670,8 @@ on_setup (GdmSessionWorker *worker,
worker->priv->service = g_strdup (service);
worker->priv->x11_display_name = g_strdup (x11_display_name);
+ worker->priv->x11_display_type = g_strdup (x11_display_type);
+ worker->priv->seat_id = g_strdup (seat_id);
worker->priv->x11_authority_file = g_strdup (x11_authority_file);
worker->priv->display_device = g_strdup (console);
worker->priv->hostname = g_strdup (hostname);
@@ -2658,6 +2692,8 @@ on_setup_for_user (GdmSessionWorker *worker,
const char *x11_display_name;
+ const char *x11_display_type;
const char *x11_authority_file;
@@ -2674,6 +2710,8 @@ on_setup_for_user (GdmSessionWorker *worker,
DBUS_TYPE_STRING, &service,
DBUS_TYPE_STRING, &x11_display_name,
+ DBUS_TYPE_STRING, &x11_display_type,
+ DBUS_TYPE_STRING, &seat_id,
DBUS_TYPE_STRING, &console,
DBUS_TYPE_STRING, &hostname,
DBUS_TYPE_STRING, &x11_authority_file,
@@ -2682,6 +2720,8 @@ on_setup_for_user (GdmSessionWorker *worker,
worker->priv->service = g_strdup (service);
worker->priv->x11_display_name = g_strdup (x11_display_name);
+ worker->priv->x11_display_type = g_strdup (x11_display_type);
+ worker->priv->seat_id = g_strdup (seat_id);
worker->priv->x11_authority_file = g_strdup (x11_authority_file);
worker->priv->display_device = g_strdup (console);
worker->priv->hostname = g_strdup (hostname);
@@ -2970,6 +3010,21 @@ gdm_session_worker_finalize (GObject *object)
gdm_session_worker_unwatch_child (worker);
+ if (worker->priv->x11_display_name != NULL) {
+ g_free (worker->priv->x11_display_name);
+ worker->priv->x11_display_name = NULL;
+ if (worker->priv->x11_display_type != NULL) {
+ g_free (worker->priv->x11_display_type);
+ worker->priv->x11_display_type = NULL;
+ if (worker->priv->seat_id != NULL) {
+ g_free (worker->priv->seat_id);
+ worker->priv->seat_id = NULL;
if (worker->priv->username != NULL) {
g_free (worker->priv->username);
worker->priv->username = NULL;
index 04c0485..83a1036 100644
@@ -385,6 +385,10 @@ start_session_timeout (GdmSimpleSlave *slave)
+ /* Defer requests to use this display from ConsoleKit
+ gdm_slave_block_console_session_requests_on_display (GDM_SLAVE (slave));
@@ -399,6 +403,7 @@ start_session_timeout (GdmSimpleSlave *slave)
gdm_session_start_session (GDM_SESSION (slave->priv->session));
+ gdm_slave_unblock_console_session_requests_on_display (GDM_SLAVE (slave));
slave->priv->start_session_id = 0;
@@ -600,6 +605,16 @@ on_default_session_name_changed (GdmSession *session,
+on_console_session_changed (GdmSession *session,
+ g_debug ("GdmSimpleSlave: Default session name changed: %s", text);
+ gdm_slave_set_console_session_id (GDM_SLAVE (slave), text);
create_new_session (GdmSimpleSlave *slave)
gboolean display_is_local;
@@ -634,6 +649,7 @@ create_new_session (GdmSimpleSlave *slave)
g_free (display_hostname);
+ g_free (display_x11_authority_file);
g_signal_connect (slave->priv->session,
@@ -740,6 +756,11 @@ create_new_session (GdmSimpleSlave *slave)
"default-session-name-changed",
G_CALLBACK (on_default_session_name_changed),
+ g_signal_connect (slave->priv->session,
+ "notify::display-console-session",
+ G_CALLBACK (on_console_session_changed),
@@ -907,6 +928,8 @@ start_greeter (GdmSimpleSlave *slave)
gboolean display_is_local;
@@ -918,6 +941,8 @@ start_greeter (GdmSimpleSlave *slave)
display_is_local = FALSE;
@@ -926,6 +951,8 @@ start_greeter (GdmSimpleSlave *slave)
"display-id", &display_id,
"display-is-local", &display_is_local,
"display-name", &display_name,
+ "display-seat-id", &seat_id,
+ "display-session-id", &session_id,
"display-hostname", &display_hostname,
"display-x11-authority-file", &auth_file,
@@ -1007,6 +1034,8 @@ start_greeter (GdmSimpleSlave *slave)
g_debug ("GdmSimpleSlave: Creating greeter on %s %s %s", display_name, display_device, display_hostname);
slave->priv->greeter = gdm_greeter_session_new (display_name,
@@ -1034,6 +1063,7 @@ start_greeter (GdmSimpleSlave *slave)
g_free (display_hostname);
@@ -1109,31 +1139,20 @@ on_server_died (GdmServer *server,
gdm_simple_slave_run (GdmSimpleSlave *slave)
gboolean display_is_local;
+ "display-id", &display_id,
"display-is-local", &display_is_local,
- "display-name", &display_name,
- "display-x11-authority-file", &auth_file,
/* if this is local display start a server if one doesn't
- slave->priv->server = gdm_server_new (display_name, auth_file);
- if (gdm_settings_client_get_boolean (GDM_KEY_DISALLOW_TCP,
- g_object_set (slave->priv->server,
- "disable-tcp", disable_tcp,
+ slave->priv->server = gdm_server_new (display_id);
g_signal_connect (slave->priv->server,
@@ -1166,8 +1185,7 @@ gdm_simple_slave_run (GdmSimpleSlave *slave)
g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
@@ -81,11 +81,13 @@ struct GdmSlavePrivate
/* cached display values */
gboolean display_is_local;
gboolean display_is_parented;
+ char *display_session_id;
char *display_x11_authority_file;
char *parent_display_name;
char *parent_display_x11_authority_file;
@@ -101,10 +103,12 @@ enum {
+ PROP_DISPLAY_SESSION_ID,
PROP_DISPLAY_X11_AUTHORITY_FILE
@@ -661,6 +665,24 @@ gdm_slave_real_start (GdmSlave *slave)
res = dbus_g_proxy_call (slave->priv->display_proxy,
+ G_TYPE_STRING, &slave->priv->display_type,
+ g_warning ("Failed to get value: %s", error->message);
+ g_warning ("Failed to get value");
+ res = dbus_g_proxy_call (slave->priv->display_proxy,
@@ -750,6 +772,24 @@ gdm_slave_real_start (GdmSlave *slave)
+ res = dbus_g_proxy_call (slave->priv->display_proxy,
+ G_TYPE_STRING, &slave->priv->display_session_id,
+ g_warning ("Failed to get value: %s", error->message);
+ g_warning ("Failed to get value");
@@ -805,6 +845,34 @@ gdm_slave_stopped (GdmSlave *slave)
g_signal_emit (slave, signals [STOPPED], 0);
+gdm_slave_set_console_session_id (GdmSlave *slave,
+ const char *session_id)
+ g_debug ("GdmSlave: Informing display of new session id");
+ res = dbus_g_proxy_call (slave->priv->display_proxy,
+ G_TYPE_STRING, session_id,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+ g_warning ("Failed to set console session id: %s", error->message);
+ g_warning ("Failed to set console session id");
+ g_debug ("GdmSlave: Set console session id");
gdm_slave_add_user_authorization (GdmSlave *slave,
@@ -1370,6 +1438,59 @@ gdm_slave_switch_to_user_session (GdmSlave *slave,
+gdm_slave_block_console_session_requests_on_display (GdmSlave *slave)
+ g_debug ("GdmSlave: Asking display to ignore ConsoleKit");
+ res = dbus_g_proxy_call (slave->priv->display_proxy,
+ "BlockConsoleSessionRequests",
+ G_TYPE_INVALID, G_TYPE_INVALID);
+ g_warning ("Failed to get display to ignore ConsoleKit: %s", error->message);
+ g_warning ("Failed to get display to ignore ConsoleKit");
+ g_debug ("GdmSlave: Display is now ignoring ConsoleKit");
+gdm_slave_unblock_console_session_requests_on_display (GdmSlave *slave)
+ g_debug ("GdmSlave: Informing display to stop ignoring ConsoleKit");
+ res = dbus_g_proxy_call (slave->priv->display_proxy,
+ "UnblockConsoleSessionRequests",
+ G_TYPE_INVALID, G_TYPE_INVALID);
+ g_warning ("Failed to get display to stop ignoring ConsoleKit: %s", error->message);
+ g_warning ("Failed to get display to stop ignoring ConsoleKit");
+ g_debug ("GdmSlave: Display is no longer ignoring ConsoleKit");
_gdm_slave_set_display_id (GdmSlave *slave,
@@ -1386,6 +1507,15 @@ _gdm_slave_set_display_name (GdmSlave *slave,
slave->priv->display_name = g_strdup (name);
+_gdm_slave_set_display_type (GdmSlave *slave,
+ g_free (slave->priv->display_type);
+ slave->priv->display_type = g_strdup (type);
_gdm_slave_set_display_number (GdmSlave *slave,
@@ -1418,6 +1548,14 @@ _gdm_slave_set_display_seat_id (GdmSlave *slave,
+_gdm_slave_set_display_session_id (GdmSlave *slave,
+ g_free (slave->priv->display_session_id);
+ slave->priv->display_session_id = g_strdup (id);
_gdm_slave_set_display_is_local (GdmSlave *slave,
@@ -1441,6 +1579,9 @@ gdm_slave_set_property (GObject *object,
_gdm_slave_set_display_name (self, g_value_get_string (value));
+ case PROP_DISPLAY_TYPE:
+ _gdm_slave_set_display_type (self, g_value_get_string (value));
case PROP_DISPLAY_NUMBER:
_gdm_slave_set_display_number (self, g_value_get_int (value));
@@ -1450,6 +1591,9 @@ gdm_slave_set_property (GObject *object,
case PROP_DISPLAY_SEAT_ID:
_gdm_slave_set_display_seat_id (self, g_value_get_string (value));
+ case PROP_DISPLAY_SESSION_ID:
+ _gdm_slave_set_display_session_id (self, g_value_get_string (value));
case PROP_DISPLAY_X11_AUTHORITY_FILE:
_gdm_slave_set_display_x11_authority_file (self, g_value_get_string (value));
@@ -1479,6 +1623,9 @@ gdm_slave_get_property (GObject *object,
g_value_set_string (value, self->priv->display_name);
+ case PROP_DISPLAY_TYPE:
+ g_value_set_string (value, self->priv->display_type);
case PROP_DISPLAY_NUMBER:
g_value_set_int (value, self->priv->display_number);
@@ -1488,6 +1635,9 @@ gdm_slave_get_property (GObject *object,
case PROP_DISPLAY_SEAT_ID:
g_value_set_string (value, self->priv->display_seat_id);
+ case PROP_DISPLAY_SESSION_ID:
+ g_value_set_string (value, self->priv->display_session_id);
case PROP_DISPLAY_X11_AUTHORITY_FILE:
g_value_set_string (value, self->priv->display_x11_authority_file);
@@ -1582,6 +1732,13 @@ gdm_slave_class_init (GdmSlaveClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
+ g_param_spec_string ("display-type",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
g_param_spec_int ("display-number",
@@ -1605,6 +1762,13 @@ gdm_slave_class_init (GdmSlaveClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
+ PROP_DISPLAY_SESSION_ID,
+ g_param_spec_string ("display-session-id",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
PROP_DISPLAY_X11_AUTHORITY_FILE,
g_param_spec_string ("display-x11-authority-file",
@@ -1659,6 +1823,7 @@ gdm_slave_finalize (GObject *object)
g_free (slave->priv->id);
g_free (slave->priv->display_id);
g_free (slave->priv->display_name);
+ g_free (slave->priv->display_type);
g_free (slave->priv->display_hostname);
g_free (slave->priv->display_seat_id);
g_free (slave->priv->display_x11_authority_file);
index af28b00..3783c2a 100644
@@ -72,13 +72,17 @@ gboolean gdm_slave_add_user_authorization (GdmSlave *slave,
gboolean gdm_slave_switch_to_user_session (GdmSlave *slave,
+void gdm_slave_block_console_session_requests_on_display (GdmSlave *slave);
+void gdm_slave_unblock_console_session_requests_on_display (GdmSlave *slave);
gboolean gdm_slave_connect_to_x11_display (GdmSlave *slave);
void gdm_slave_set_busy_cursor (GdmSlave *slave);
gboolean gdm_slave_run_script (GdmSlave *slave,
void gdm_slave_stopped (GdmSlave *slave);
+void gdm_slave_set_console_session_id (GdmSlave *slave,
+ const char *session_id);
#endif /* __GDM_SLAVE_H */
index 0ef5c5a..8189f1e 100644
@@ -66,6 +66,8 @@ struct GdmWelcomeSessionPrivate
+ char *x11_display_seat_id;
+ char *x11_display_session_id;
char *x11_display_device;
char *x11_display_hostname;
char *x11_authority_file;
@@ -86,6 +88,8 @@ struct GdmWelcomeSessionPrivate
+ PROP_X11_DISPLAY_SEAT_ID,
+ PROP_X11_DISPLAY_SESSION_ID,
PROP_X11_DISPLAY_HOSTNAME,
@@ -135,6 +139,8 @@ open_welcome_session (GdmWelcomeSession *welcome_session)
const char *session_type;
const char *x11_display_device;
+ const char *session_id;
@@ -170,6 +176,18 @@ open_welcome_session (GdmWelcomeSession *welcome_session)
+ if (welcome_session->priv->x11_display_seat_id != NULL) {
+ seat_id = welcome_session->priv->x11_display_seat_id;
+ if (welcome_session->priv->x11_display_session_id != NULL) {
+ session_id = welcome_session->priv->x11_display_session_id;
g_debug ("GdmWelcomeSession: Opening ConsoleKit session for user:%d x11-display:'%s' x11-display-device:'%s' remote-host-name:'%s' is-local:%d",
welcome_session->priv->x11_display_name,
@@ -183,6 +201,8 @@ open_welcome_session (GdmWelcomeSession *welcome_session)
"unix-user", &pwent->pw_uid,
"session-type", &session_type,
"x11-display", &welcome_session->priv->x11_display_name,
+ "session", &session_id,
"x11-display-device", &x11_display_device,
"remote-host-name", &hostname,
"is-local", &welcome_session->priv->x11_display_is_local,
@@ -1032,6 +1052,22 @@ _gdm_welcome_session_set_x11_display_name (GdmWelcomeSession *welcome_session,
+_gdm_welcome_session_set_x11_display_seat_id (GdmWelcomeSession *welcome_session,
+ g_free (welcome_session->priv->x11_display_seat_id);
+ welcome_session->priv->x11_display_seat_id = g_strdup (sid);
+_gdm_welcome_session_set_x11_display_session_id (GdmWelcomeSession *welcome_session,
+ g_free (welcome_session->priv->x11_display_session_id);
+ welcome_session->priv->x11_display_session_id = g_strdup (ssid);
_gdm_welcome_session_set_x11_display_hostname (GdmWelcomeSession *welcome_session,
@@ -1054,7 +1090,6 @@ _gdm_welcome_session_set_x11_display_is_local (GdmWelcomeSession *welcome_sessio
welcome_session->priv->x11_display_is_local = is_local;
_gdm_welcome_session_set_x11_authority_file (GdmWelcomeSession *welcome_session,
@@ -1140,6 +1175,12 @@ gdm_welcome_session_set_property (GObject *object,
case PROP_X11_DISPLAY_NAME:
_gdm_welcome_session_set_x11_display_name (self, g_value_get_string (value));
+ case PROP_X11_DISPLAY_SEAT_ID:
+ _gdm_welcome_session_set_x11_display_seat_id (self, g_value_get_string (value));
+ case PROP_X11_DISPLAY_SESSION_ID:
+ _gdm_welcome_session_set_x11_display_session_id (self, g_value_get_string (value));
case PROP_X11_DISPLAY_HOSTNAME:
_gdm_welcome_session_set_x11_display_hostname (self, g_value_get_string (value));
@@ -1199,6 +1240,12 @@ gdm_welcome_session_get_property (GObject *object,
case PROP_X11_DISPLAY_NAME:
g_value_set_string (value, self->priv->x11_display_name);
+ case PROP_X11_DISPLAY_SEAT_ID:
+ g_value_set_string (value, self->priv->x11_display_seat_id);
+ case PROP_X11_DISPLAY_SESSION_ID:
+ g_value_set_string (value, self->priv->x11_display_session_id);
case PROP_X11_DISPLAY_HOSTNAME:
g_value_set_string (value, self->priv->x11_display_hostname);
@@ -1278,6 +1325,20 @@ gdm_welcome_session_class_init (GdmWelcomeSessionClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
+ PROP_X11_DISPLAY_SEAT_ID,
+ g_param_spec_string ("x11-display-seat-id",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_X11_DISPLAY_SESSION_ID,
+ g_param_spec_string ("x11-display-session-id",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
PROP_X11_DISPLAY_HOSTNAME,
g_param_spec_string ("x11-display-hostname",
@@ -1442,6 +1503,7 @@ gdm_welcome_session_finalize (GObject *object)
g_free (welcome_session->priv->group_name);
g_free (welcome_session->priv->runtime_dir);
g_free (welcome_session->priv->x11_display_name);
+ g_free (welcome_session->priv->x11_display_seat_id);
g_free (welcome_session->priv->x11_display_device);
g_free (welcome_session->priv->x11_display_hostname);
g_free (welcome_session->priv->x11_authority_file);
@@ -224,7 +224,7 @@ gdm_xdmcp_chooser_display_new (const char *hostname,
"remote-hostname", hostname,
"x11-display-number", number,
"x11-display-name", x11_display,
"remote-address", address,
"session-number", session_number,
# Plus a lot of fun stuff added
index 60d7624..3ee1a67 100644
-e 's,[@]libexecdir[@],$(libexecdir),g' \
- sed -e 's,[@]X_PATH[@],$(X_PATH),g' \
- sed -e 's,[@]X_PATH[@],$(X_PATH),g' \
- sed -e 's,[@]X_PATH[@],$(X_PATH),g' \
sed -e 's,[@]GDM_DEFAULTS_CONF[@],$(GDM_DEFAULTS_CONF),g' \
index c52d3c2..54276fd 100755
index cfabee7..09ad05b 100755
# Note that output goes into the .xsession-errors file for easy debugging
index 514117d..8c551ce 100644
- <signature>b</signature>
- <default>true</default>
@@ -1364,18 +1364,6 @@ TimedLogin=you
<title>[security]</title>
- <term>DisallowTCP</term>
- <synopsis>DisallowTCP=true</synopsis>
- If true, then always append <filename>-nolisten tcp</filename>
- to the command line when starting attached Xservers, thus
- disallowing TCP connection. This is a more secure
- configuration if you are not using remote connections.