[gdm/multi-stack: 7/22] Make greeter/autologin session explicitly request PAM conversation
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm/multi-stack: 7/22] Make greeter/autologin session explicitly request PAM conversation
- Date: Wed, 7 Jul 2010 21:24:09 +0000 (UTC)
commit f1ea71bcd26119f3d7a9564353562351f6840d3c
Author: Ray Strode <rstrode redhat com>
Date: Fri Jan 16 13:01:48 2009 -0500
Make greeter/autologin session explicitly request PAM conversation
Now the greeter (and also the autologin code) has to say what
PAM stack it wants the slave to run. When that stack is ready,
we emit the Ready signal as before, but now the Ready signal
carries a string argument saying which service is ready to
converse.
When we support multiple PAM stacks, the greeter will call
StartConversation for each stack, and will keep the UI
associated with each stack disabled until the Ready signals
come back one-by-one.
daemon/gdm-factory-slave.c | 3 +-
daemon/gdm-greeter-server.c | 53 ++++++++++++++++++++++++++++--
daemon/gdm-greeter-server.h | 5 ++-
daemon/gdm-simple-slave.c | 32 +++++++++++++++++-
gui/simple-greeter/gdm-greeter-client.c | 18 ++++++----
gui/simple-greeter/gdm-greeter-client.h | 4 ++-
gui/simple-greeter/gdm-greeter-session.c | 4 ++
7 files changed, 104 insertions(+), 15 deletions(-)
---
diff --git a/daemon/gdm-factory-slave.c b/daemon/gdm-factory-slave.c
index 09cdf5d..b530e68 100644
--- a/daemon/gdm-factory-slave.c
+++ b/daemon/gdm-factory-slave.c
@@ -186,7 +186,8 @@ on_session_conversation_started (GdmSession *session,
{
g_debug ("GdmFactorySlave: session conversation started");
- gdm_greeter_server_ready (slave->priv->greeter_server);
+ gdm_greeter_server_ready (slave->priv->greeter_server,
+ service_name);
}
static void
diff --git a/daemon/gdm-greeter-server.c b/daemon/gdm-greeter-server.c
index 0c67f1e..8640ad4 100644
--- a/daemon/gdm-greeter-server.c
+++ b/daemon/gdm-greeter-server.c
@@ -70,6 +70,7 @@ enum {
};
enum {
+ START_CONVERSATION,
BEGIN_AUTO_LOGIN,
BEGIN_VERIFICATION,
BEGIN_VERIFICATION_FOR_USER,
@@ -247,9 +248,10 @@ gdm_greeter_server_reset (GdmGreeterServer *greeter_server)
}
gboolean
-gdm_greeter_server_ready (GdmGreeterServer *greeter_server)
+gdm_greeter_server_ready (GdmGreeterServer *greeter_server,
+ const char *service_name)
{
- send_dbus_void_signal (greeter_server, "Ready");
+ send_dbus_string_signal (greeter_server, "Ready", service_name);
return TRUE;
}
@@ -324,6 +326,34 @@ generate_address (void)
}
static DBusHandlerResult
+handle_start_conversation (GdmGreeterServer *greeter_server,
+ DBusConnection *connection,
+ DBusMessage *message)
+{
+ DBusMessage *reply;
+ DBusError error;
+ const char *service_name;
+
+ dbus_error_init (&error);
+ if (! dbus_message_get_args (message, &error,
+ DBUS_TYPE_STRING, &service_name,
+ DBUS_TYPE_INVALID)) {
+ g_warning ("ERROR: %s", error.message);
+ }
+ dbus_error_free (&error);
+
+ g_debug ("GreeterServer: StartConversation");
+
+ reply = dbus_message_new_method_return (message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
+
+ g_signal_emit (greeter_server, signals [START_CONVERSATION], 0, service_name);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+static DBusHandlerResult
handle_begin_verification (GdmGreeterServer *greeter_server,
DBusConnection *connection,
DBusMessage *message)
@@ -646,7 +676,9 @@ greeter_handle_child_message (DBusConnection *connection,
{
GdmGreeterServer *greeter_server = GDM_GREETER_SERVER (user_data);
- if (dbus_message_is_method_call (message, GDM_GREETER_SERVER_DBUS_INTERFACE, "BeginVerification")) {
+ if (dbus_message_is_method_call (message, GDM_GREETER_SERVER_DBUS_INTERFACE, "StartConversation")) {
+ return handle_start_conversation (greeter_server, connection, message);
+ } else if (dbus_message_is_method_call (message, GDM_GREETER_SERVER_DBUS_INTERFACE, "BeginVerification")) {
return handle_begin_verification (greeter_server, connection, message);
} else if (dbus_message_is_method_call (message, GDM_GREETER_SERVER_DBUS_INTERFACE, "BeginVerificationForUser")) {
return handle_begin_verification_for_user (greeter_server, connection, message);
@@ -700,7 +732,11 @@ do_introspect (DBusConnection *connection,
/* interface */
xml = g_string_append (xml,
" <interface name=\"org.gnome.DisplayManager.GreeterServer\">\n"
+ " <method name=\"StartConversation\">\n"
+ " <arg name=\"service_name\" direction=\"in\" type=\"s\"/>\n"
+ " </method>\n"
" <method name=\"BeginVerification\">\n"
+ " </method>\n"
" <method name=\"BeginTimedLogin\">\n"
" </method>\n"
" <method name=\"BeginVerificationForUser\">\n"
@@ -760,6 +796,7 @@ do_introspect (DBusConnection *connection,
" <arg name=\"delay\" type=\"i\"/>\n"
" </signal>\n"
" <signal name=\"Ready\">\n"
+ " <arg name=\"service-name\" type=\"s\"/>\n"
" </signal>\n"
" <signal name=\"Reset\">\n"
" </signal>\n"
@@ -1122,6 +1159,16 @@ gdm_greeter_server_class_init (GdmGreeterServerClass *klass)
"group name",
GDM_GROUPNAME,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ signals [START_CONVERSATION] =
+ g_signal_new ("start-conversation",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmGreeterServerClass, start_conversation),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1, G_TYPE_STRING);
signals [BEGIN_VERIFICATION] =
g_signal_new ("begin-verification",
G_OBJECT_CLASS_TYPE (object_class),
diff --git a/daemon/gdm-greeter-server.h b/daemon/gdm-greeter-server.h
index 6e92100..7333db1 100644
--- a/daemon/gdm-greeter-server.h
+++ b/daemon/gdm-greeter-server.h
@@ -45,6 +45,8 @@ typedef struct
{
GObjectClass parent_class;
+ void (* start_conversation) (GdmGreeterServer *greeter_server,
+ const char *service_name);
void (* begin_auto_login) (GdmGreeterServer *greeter_server);
void (* begin_verification) (GdmGreeterServer *greeter_server);
void (* begin_verification_for_user)(GdmGreeterServer *greeter_server,
@@ -85,7 +87,8 @@ gboolean gdm_greeter_server_info (GdmGreeterServer *
gboolean gdm_greeter_server_problem (GdmGreeterServer *greeter_server,
const char *text);
gboolean gdm_greeter_server_reset (GdmGreeterServer *greeter_server);
-gboolean gdm_greeter_server_ready (GdmGreeterServer *greeter_server);
+gboolean gdm_greeter_server_ready (GdmGreeterServer *greeter_server,
+ const char *service_name);
void gdm_greeter_server_selected_user_changed (GdmGreeterServer *greeter_server,
const char *text);
void gdm_greeter_server_default_language_name_changed (GdmGreeterServer *greeter_server,
diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c
index 7bc6e02..fe4e172 100644
--- a/daemon/gdm-simple-slave.c
+++ b/daemon/gdm-simple-slave.c
@@ -524,6 +524,7 @@ on_session_secret_info_query (GdmSession *session,
static void
on_session_conversation_started (GdmSession *session,
+ const char *service_name,
GdmSimpleSlave *slave)
{
gboolean res;
@@ -533,7 +534,8 @@ on_session_conversation_started (GdmSession *session,
g_debug ("GdmSimpleSlave: session conversation started");
if (slave->priv->greeter_server != NULL) {
- res = gdm_greeter_server_ready (slave->priv->greeter_server);
+ res = gdm_greeter_server_ready (slave->priv->greeter_server,
+ service_name);
if (! res) {
g_warning ("Unable to send ready");
}
@@ -549,8 +551,10 @@ on_session_conversation_started (GdmSession *session,
gdm_greeter_server_request_timed_login (slave->priv->greeter_server, username, delay);
} else {
g_debug ("GdmSimpleSlave: begin auto login for user '%s'", username);
+ /* service_name will be "gdm-autologin"
+ */
gdm_session_setup_for_user (GDM_SESSION (slave->priv->session),
- "gdm-autologin",
+ service_name,
username);
}
@@ -782,6 +786,16 @@ on_greeter_session_died (GdmGreeterSession *greeter,
}
static void
+on_greeter_start_conversation (GdmGreeterServer *greeter_server,
+ const char *service_name,
+ GdmSimpleSlave *slave)
+{
+ g_debug ("GdmSimpleSlave: starting conversation with '%s' pam service'", service_name);
+ gdm_session_start_conversation (GDM_SESSION (slave->priv->session),
+ service_name);
+}
+
+static void
on_greeter_begin_verification (GdmGreeterServer *greeter_server,
GdmSimpleSlave *slave)
{
@@ -956,6 +970,10 @@ start_greeter (GdmSimpleSlave *slave)
slave->priv->greeter_server = gdm_greeter_server_new (display_id);
g_signal_connect (slave->priv->greeter_server,
+ "start-conversation",
+ G_CALLBACK (on_greeter_start_conversation),
+ slave);
+ g_signal_connect (slave->priv->greeter_server,
"begin-auto-login",
G_CALLBACK (on_greeter_begin_auto_login),
slave);
@@ -1066,10 +1084,20 @@ idle_connect_to_display (GdmSimpleSlave *slave)
if (! enabled || delay > 0) {
start_greeter (slave);
create_new_session (slave);
+
+ if (enabled) {
+ g_debug ("GdmSimpleSlave: Starting timed login conversation");
+ gdm_session_start_conversation (GDM_SESSION (slave->priv->session),
+ "gdm-autologin");
+ }
} else {
/* Run the init script. gdmslave suspends until script has terminated */
gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR "/Init", GDM_USERNAME);
reset_session (slave);
+
+ g_debug ("GdmSimpleSlave: Starting automatic login conversation");
+ gdm_session_start_conversation (GDM_SESSION (slave->priv->session),
+ "gdm-autologin");
}
} else {
if (slave->priv->connection_attempts >= MAX_CONNECT_ATTEMPTS) {
diff --git a/gui/simple-greeter/gdm-greeter-client.c b/gui/simple-greeter/gdm-greeter-client.c
index ed4dd95..8d061a4 100644
--- a/gui/simple-greeter/gdm-greeter-client.c
+++ b/gui/simple-greeter/gdm-greeter-client.c
@@ -237,11 +237,7 @@ static void
on_ready (GdmGreeterClient *client,
DBusMessage *message)
{
- g_debug ("GdmGreeterClient: Ready");
-
- g_signal_emit (client,
- gdm_greeter_client_signals[READY],
- 0);
+ emit_string_signal_for_message (client, "Ready", message, READY);
}
static void
@@ -400,6 +396,14 @@ send_dbus_void_method (DBusConnection *connection,
}
void
+gdm_greeter_client_call_start_conversation (GdmGreeterClient *client,
+ const char *service_name)
+{
+ send_dbus_string_method (client->priv->connection,
+ "StartConversation", service_name);
+}
+
+void
gdm_greeter_client_call_begin_auto_login (GdmGreeterClient *client,
const char *username)
{
@@ -879,9 +883,9 @@ gdm_greeter_client_class_init (GdmGreeterClientClass *klass)
G_STRUCT_OFFSET (GdmGreeterClientClass, ready),
NULL,
NULL,
- g_cclosure_marshal_VOID__VOID,
+ g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE,
- 0);
+ 1, G_TYPE_STRING);
gdm_greeter_client_signals[RESET] =
g_signal_new ("reset",
diff --git a/gui/simple-greeter/gdm-greeter-client.h b/gui/simple-greeter/gdm-greeter-client.h
index 08deabd..88b0281 100644
--- a/gui/simple-greeter/gdm-greeter-client.h
+++ b/gui/simple-greeter/gdm-greeter-client.h
@@ -84,13 +84,15 @@ GQuark gdm_greeter_client_error_quark (void);
GdmGreeterClient * gdm_greeter_client_new (void);
gboolean gdm_greeter_client_start (GdmGreeterClient *client,
- GError **error);
+ GError **error);
void gdm_greeter_client_stop (GdmGreeterClient *client);
gboolean gdm_greeter_client_get_display_is_local (GdmGreeterClient *client);
char * gdm_greeter_client_call_get_display_id (GdmGreeterClient *client);
+void gdm_greeter_client_call_start_conversation (GdmGreeterClient *client,
+ const char *service_name);
void gdm_greeter_client_call_begin_auto_login (GdmGreeterClient *client,
const char *username);
void gdm_greeter_client_call_begin_verification (GdmGreeterClient *client);
diff --git a/gui/simple-greeter/gdm-greeter-session.c b/gui/simple-greeter/gdm-greeter-session.c
index 3b89bc8..5368e61 100644
--- a/gui/simple-greeter/gdm-greeter-session.c
+++ b/gui/simple-greeter/gdm-greeter-session.c
@@ -85,6 +85,7 @@ on_problem (GdmGreeterClient *client,
static void
on_ready (GdmGreeterClient *client,
+ const char *service_name,
GdmGreeterSession *session)
{
g_debug ("GdmGreeterSession: Ready");
@@ -264,6 +265,7 @@ on_cancelled (GdmGreeterLoginWindow *login_window,
{
gdm_greeter_panel_hide_user_options (GDM_GREETER_PANEL (session->priv->panel));
gdm_greeter_client_call_cancel (session->priv->client);
+ gdm_greeter_client_call_start_conversation (session->priv->client, "gdm");
}
static void
@@ -428,6 +430,8 @@ gdm_greeter_session_start (GdmGreeterSession *session,
toggle_panel (session, TRUE);
toggle_login_window (session, TRUE);
+ gdm_greeter_client_call_start_conversation (session->priv->client, "gdm");
+
gdm_profile_end (NULL);
return res;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]