summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2009-06-23 22:41:09 -0400
committerRay Strode <rstrode@redhat.com>2009-08-03 15:50:57 -0400
commitbb7c5cc01dbef5b5f8e4cfba9ccd825cfcaecb3e (patch)
tree28c91ebc94450c2446137c1687e202420dabc209
parent04a020a046b0b2d974c065c302d5a82d643a69fb (diff)
downloadgdm-bb7c5cc01dbef5b5f8e4cfba9ccd825cfcaecb3e.tar.gz
Update session-id on display after login
When the user logs in the greeter session is closed and a new one is opened. We want to make sure the display the user logged in at knows about the new session running on it.
-rw-r--r--daemon/gdm-display.c10
-rw-r--r--daemon/gdm-display.h3
-rw-r--r--daemon/gdm-display.xml3
-rw-r--r--daemon/gdm-session-direct.c54
-rw-r--r--daemon/gdm-session-worker.c7
-rw-r--r--daemon/gdm-simple-slave.c15
-rw-r--r--daemon/gdm-slave.c28
-rw-r--r--daemon/gdm-slave.h3
8 files changed, 122 insertions, 1 deletions
diff --git a/daemon/gdm-display.c b/daemon/gdm-display.c
index 0264dedc..ff0f2a70 100644
--- a/daemon/gdm-display.c
+++ b/daemon/gdm-display.c
@@ -868,6 +868,16 @@ _gdm_display_set_session_id (GdmDisplay *display,
display->priv->session_id = g_strdup (session_id);
}
+gboolean
+gdm_display_set_session_id (GdmDisplay *display,
+ const char *session_id,
+ GError **error)
+{
+ _gdm_display_set_session_id (display, session_id);
+ g_object_notify (G_OBJECT (display), "session-id");
+ return TRUE;
+}
+
static void
_gdm_display_set_remote_hostname (GdmDisplay *display,
const char *hostname)
diff --git a/daemon/gdm-display.h b/daemon/gdm-display.h
index fffc1956..6c494fd1 100644
--- a/daemon/gdm-display.h
+++ b/daemon/gdm-display.h
@@ -142,6 +142,9 @@ gboolean gdm_display_get_x11_cookie (GdmDisplay *disp
gboolean gdm_display_get_x11_authority_file (GdmDisplay *display,
char **filename,
GError **error);
+gboolean gdm_display_set_session_id (GdmDisplay *display,
+ const char *text,
+ GError **error);
gboolean gdm_display_add_user_authorization (GdmDisplay *display,
const char *username,
char **filename,
diff --git a/daemon/gdm-display.xml b/daemon/gdm-display.xml
index c8bd803d..21b98c82 100644
--- a/daemon/gdm-display.xml
+++ b/daemon/gdm-display.xml
@@ -44,6 +44,9 @@
<method name="RemoveUserAuthorization">
<arg name="username" direction="in" type="s"/>
</method>
+ <method name="SetSessionId">
+ <arg name="session_id" direction="in" type="s"/>
+ </method>
<method name="SetSlaveBusName">
<arg name="name" direction="in" type="s"/>
</method>
diff --git a/daemon/gdm-session-direct.c b/daemon/gdm-session-direct.c
index e1ea8a02..1a08aede 100644
--- a/daemon/gdm-session-direct.c
+++ b/daemon/gdm-session-direct.c
@@ -88,6 +88,7 @@ struct _GdmSessionDirectPrivate
char *display_hostname;
char *display_device;
char *display_x11_authority_file;
+ char *display_console_session;
gboolean display_is_local;
DBusServer *server;
@@ -104,6 +105,7 @@ enum {
PROP_DISPLAY_IS_LOCAL,
PROP_DISPLAY_DEVICE,
PROP_DISPLAY_X11_AUTHORITY_FILE,
+ PROP_DISPLAY_CONSOLE_SESSION,
PROP_USER_X11_AUTHORITY_FILE,
};
@@ -732,6 +734,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,
+ DBusMessage *message)
+{
+ DBusMessage *reply;
+ DBusError error;
+ const char *text;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &text,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
+
+ 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'",
+ text);
+
+
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
static void
cancel_pending_query (GdmSessionDirect *session)
{
@@ -1162,6 +1192,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, "SessionStarted")) {
return gdm_session_direct_handle_session_started (session, connection, message);
} else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "StartFailed")) {
@@ -2189,6 +2221,14 @@ _gdm_session_direct_set_display_x11_authority_file (GdmSessionDirect *session,
}
static void
+_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);
+}
+
+static void
_gdm_session_direct_set_display_is_local (GdmSessionDirect *session,
gboolean is)
{
@@ -2224,6 +2264,9 @@ 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));
break;
+ case PROP_DISPLAY_CONSOLE_SESSION:
+ _gdm_session_direct_set_display_console_session (self, g_value_get_string (value));
+ break;
case PROP_DISPLAY_IS_LOCAL:
_gdm_session_direct_set_display_is_local (self, g_value_get_boolean (value));
break;
@@ -2262,6 +2305,9 @@ gdm_session_direct_get_property (GObject *object,
case PROP_DISPLAY_X11_AUTHORITY_FILE:
g_value_set_string (value, self->priv->display_x11_authority_file);
break;
+ case PROP_DISPLAY_CONSOLE_SESSION:
+ g_value_set_string (value, self->priv->display_console_session);
+ break;
case PROP_DISPLAY_IS_LOCAL:
g_value_set_boolean (value, self->priv->display_is_local);
break;
@@ -2460,6 +2506,14 @@ gdm_session_direct_class_init (GdmSessionDirectClass *session_class)
"display x11 authority file",
NULL,
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",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/* not construct only */
g_object_class_install_property (object_class,
PROP_USER_X11_AUTHORITY_FILE,
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
index c1331df6..0d279825 100644
--- a/daemon/gdm-session-worker.c
+++ b/daemon/gdm-session-worker.c
@@ -1569,6 +1569,7 @@ static void
register_ck_session (GdmSessionWorker *worker)
{
const char *session_cookie;
+ const char *session_id;
gboolean res;
session_cookie = NULL;
@@ -1581,6 +1582,12 @@ register_ck_session (GdmSessionWorker *worker)
"XDG_SESSION_COOKIE",
session_cookie);
}
+
+ session_id = ck_connector_get_session_id (worker->priv->ckc);
+
+ send_dbus_string_method (worker->priv->connection,
+ "DisplayConsoleSessionUpdated",
+ session_id);
}
static void
diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c
index 0f2bd542..a3b41410 100644
--- a/daemon/gdm-simple-slave.c
+++ b/daemon/gdm-simple-slave.c
@@ -568,6 +568,16 @@ on_default_session_name_changed (GdmSession *session,
}
static void
+on_console_session_changed (GdmSession *session,
+ const char *text,
+ GdmSimpleSlave *slave)
+{
+ g_debug ("GdmSimpleSlave: Default session name changed: %s", text);
+
+ gdm_slave_set_console_session_id (GDM_SLAVE (slave), text);
+}
+
+static void
create_new_session (GdmSimpleSlave *slave)
{
gboolean display_is_local;
@@ -700,6 +710,11 @@ create_new_session (GdmSimpleSlave *slave)
"default-session-name-changed",
G_CALLBACK (on_default_session_name_changed),
slave);
+
+ g_signal_connect (slave->priv->session,
+ "notify::display-console-session",
+ G_CALLBACK (on_console_session_changed),
+ slave);
}
static void
diff --git a/daemon/gdm-slave.c b/daemon/gdm-slave.c
index e77a11cf..e88111d9 100644
--- a/daemon/gdm-slave.c
+++ b/daemon/gdm-slave.c
@@ -750,6 +750,34 @@ gdm_slave_stopped (GdmSlave *slave)
g_signal_emit (slave, signals [STOPPED], 0);
}
+void
+gdm_slave_set_console_session_id (GdmSlave *slave,
+ const char *session_id)
+{
+ gboolean res;
+ GError *error;
+
+ g_debug ("GdmSlave: Informing display of new session id");
+
+ error = NULL;
+ res = dbus_g_proxy_call (slave->priv->display_proxy,
+ "SetConsoleSessionId",
+ &error,
+ G_TYPE_STRING, session_id,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+
+ if (! res) {
+ if (error != NULL) {
+ g_warning ("Failed to set console session id: %s", error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Failed to set console session id");
+ }
+ } else {
+ g_debug ("GdmSlave: Set console session id");
+ }
+}
+
gboolean
gdm_slave_add_user_authorization (GdmSlave *slave,
const char *username,
diff --git a/daemon/gdm-slave.h b/daemon/gdm-slave.h
index af28b00f..ca370267 100644
--- a/daemon/gdm-slave.h
+++ b/daemon/gdm-slave.h
@@ -78,7 +78,8 @@ gboolean gdm_slave_run_script (GdmSlave *slave,
const char *dir,
const char *username);
void gdm_slave_stopped (GdmSlave *slave);
-
+void gdm_slave_set_console_session_id (GdmSlave *slave,
+ const char *session_id);
G_END_DECLS
#endif /* __GDM_SLAVE_H */