diff options
author | William Jon McCann <mccann@jhu.edu> | 2007-11-07 19:30:58 +0000 |
---|---|---|
committer | William Jon McCann <mccann@src.gnome.org> | 2007-11-07 19:30:58 +0000 |
commit | 6e2a11d328d6b7a5e7b7d79876498134db78c585 (patch) | |
tree | 12a5360be7117e74fa048fe367ace16f583dd0bf /daemon | |
parent | 5a63165752490d1e5bb15253637685f4c50c346d (diff) | |
download | gdm-6e2a11d328d6b7a5e7b7d79876498134db78c585.tar.gz |
Split up the Verification step in the GdmSession interface into component
2007-11-07 William Jon McCann <mccann@jhu.edu>
* daemon/gdm-factory-slave.c: (greeter_reset_timeout),
(queue_greeter_reset), (on_session_setup_complete),
(on_session_setup_failed), (on_session_reset_complete),
(on_session_reset_failed), (on_session_authenticated),
(on_session_authentication_failed), (on_session_authorized),
(on_session_authorization_failed), (on_session_accredited),
(on_session_accreditation_failed), (on_greeter_begin_verification),
(on_greeter_begin_verification_for_user),
(gdm_factory_slave_start):
* daemon/gdm-product-slave.c: (on_session_setup_complete),
(on_session_setup_failed), (on_session_reset_complete),
(on_session_reset_failed), (on_session_authenticated),
(on_session_authentication_failed), (on_session_authorized),
(on_session_authorization_failed), (on_session_accredited),
(on_session_accreditation_failed), (on_relay_setup),
(on_relay_setup_for_user), (on_relay_authenticate),
(on_relay_authorize), (on_relay_establish_credentials),
(on_relay_renew_credentials), (create_new_session),
(relay_dbus_handle_message):
* daemon/gdm-session-direct.c: (send_dbus_void_signal),
(on_authentication_failed), (on_session_start_failed),
(gdm_session_direct_handle_setup_complete),
(gdm_session_direct_handle_setup_failed),
(gdm_session_direct_handle_reset_complete),
(gdm_session_direct_handle_reset_failed),
(gdm_session_direct_handle_authenticated),
(gdm_session_direct_handle_authentication_failed),
(gdm_session_direct_handle_authorized),
(gdm_session_direct_handle_authorization_failed),
(gdm_session_direct_handle_accredited),
(gdm_session_direct_handle_accreditation_failed),
(gdm_session_direct_handle_start_failed), (session_worker_message),
(do_introspect), (gdm_session_direct_init), (worker_exited),
(worker_died), (gdm_session_direct_open), (send_setup),
(send_setup_for_user), (gdm_session_direct_setup),
(gdm_session_direct_setup_for_user),
(gdm_session_direct_authenticate), (gdm_session_direct_authorize),
(gdm_session_direct_accredit), (gdm_session_direct_close),
(gdm_session_iface_init):
* daemon/gdm-session-direct.h:
* daemon/gdm-session-private.h:
* daemon/gdm-session-relay.c: (send_dbus_string_signal),
(send_dbus_void_signal), (gdm_session_relay_setup),
(gdm_session_relay_setup_for_user),
(gdm_session_relay_authenticate), (gdm_session_relay_authorize),
(gdm_session_relay_accredit), (gdm_session_relay_answer_query),
(handle_setup_complete), (handle_setup_failed),
(handle_authenticated), (handle_authentication_failed),
(handle_authorized), (handle_authorization_failed),
(handle_accredited), (handle_accreditation_failed),
(handle_session_started), (handle_session_stopped),
(handle_opened), (session_handle_child_message), (do_introspect),
(gdm_session_iface_init):
* daemon/gdm-session-worker.c: (gdm_session_execute),
(gdm_session_worker_update_username),
(gdm_session_worker_initialize_pam),
(gdm_session_worker_accredit_user), (session_worker_child_watch),
(gdm_session_worker_start_user_session), (do_setup),
(do_authenticate), (do_authorize), (do_accredit),
(do_open_session), (do_start_session), (state_change_idle),
(on_setup), (on_setup_for_user), (on_authenticate), (on_authorize),
(on_establish_credentials), (on_renew_credentials),
(worker_dbus_handle_message):
* daemon/gdm-session.c: (gdm_session_setup),
(gdm_session_setup_for_user), (gdm_session_authenticate),
(gdm_session_authorize), (gdm_session_accredit),
(gdm_session_class_init), (_gdm_session_setup_complete),
(_gdm_session_setup_failed), (_gdm_session_reset_complete),
(_gdm_session_reset_failed), (_gdm_session_authenticated),
(_gdm_session_authentication_failed), (_gdm_session_authorized),
(_gdm_session_authorization_failed), (_gdm_session_accredited),
(_gdm_session_accreditation_failed),
(_gdm_session_session_start_failed):
* daemon/gdm-session.h:
* daemon/gdm-simple-slave.c: (greeter_reset_timeout),
(queue_greeter_reset), (on_session_setup_complete),
(on_session_setup_failed), (on_session_reset_complete),
(on_session_reset_failed), (on_session_authenticated),
(on_session_authentication_failed), (on_session_authorized),
(on_session_authorization_failed), (on_session_accredited),
(on_session_accreditation_failed), (create_new_session),
(on_greeter_begin_verification),
(on_greeter_begin_verification_for_user):
* daemon/test-session.c: (on_open), (on_session_setup_complete),
(on_session_setup_failed), (on_session_reset_complete),
(on_session_reset_failed), (on_session_authenticated),
(on_session_authentication_failed), (on_session_authorized),
(on_session_authorization_failed), (on_session_accredited),
(on_session_accreditation_failed), (on_session_started),
(on_session_exited), (on_session_died), (main):
Split up the Verification step in the GdmSession interface into
component parts: setup, authenticate, authorize, accredit.
svn path=/trunk/; revision=5496
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/gdm-factory-slave.c | 171 | ||||
-rw-r--r-- | daemon/gdm-product-slave.c | 207 | ||||
-rw-r--r-- | daemon/gdm-session-direct.c | 429 | ||||
-rw-r--r-- | daemon/gdm-session-direct.h | 15 | ||||
-rw-r--r-- | daemon/gdm-session-private.h | 47 | ||||
-rw-r--r-- | daemon/gdm-session-relay.c | 301 | ||||
-rw-r--r-- | daemon/gdm-session-worker.c | 248 | ||||
-rw-r--r-- | daemon/gdm-session.c | 258 | ||||
-rw-r--r-- | daemon/gdm-session.h | 53 | ||||
-rw-r--r-- | daemon/gdm-simple-slave.c | 186 | ||||
-rw-r--r-- | daemon/test-session.c | 191 |
11 files changed, 1594 insertions, 512 deletions
diff --git a/daemon/gdm-factory-slave.c b/daemon/gdm-factory-slave.c index d7acb493..d1780975 100644 --- a/daemon/gdm-factory-slave.c +++ b/daemon/gdm-factory-slave.c @@ -92,6 +92,24 @@ static void gdm_factory_slave_finalize (GObject *object); G_DEFINE_TYPE (GdmFactorySlave, gdm_factory_slave, GDM_TYPE_SLAVE) +static gboolean +greeter_reset_timeout (GdmFactorySlave *slave) +{ + gdm_greeter_server_reset (slave->priv->greeter_server); + slave->priv->greeter_reset_id = 0; + return FALSE; +} + +static void +queue_greeter_reset (GdmFactorySlave *slave) +{ + if (slave->priv->greeter_reset_id > 0) { + return; + } + + slave->priv->greeter_reset_id = g_timeout_add_seconds (2, (GSourceFunc)greeter_reset_timeout, slave); +} + static void on_greeter_start (GdmGreeterSession *greeter, GdmFactorySlave *slave) @@ -153,43 +171,96 @@ on_session_opened (GdmSession *session, } static void -on_session_user_verified (GdmSession *session, +on_session_setup_complete (GdmSession *session, + GdmFactorySlave *slave) +{ + gdm_session_authenticate (session); +} + +static void +on_session_setup_failed (GdmSession *session, + const char *message, + GdmFactorySlave *slave) +{ + gdm_greeter_server_problem (slave->priv->greeter_server, _("Unable to initialize login system")); + + queue_greeter_reset (slave); +} + +static void +on_session_reset_complete (GdmSession *session, + GdmFactorySlave *slave) +{ + g_debug ("GdmFactorySlave: PAM reset"); +} + +static void +on_session_reset_failed (GdmSession *session, + const char *message, + GdmFactorySlave *slave) +{ + g_critical ("Unable to reset PAM"); +} + +static void +on_session_authenticated (GdmSession *session, GdmFactorySlave *slave) { - g_debug ("GdmFactorySlave: session user verified"); + gdm_session_authorize (session); +} - gdm_session_start_session (session); +static void +on_session_authentication_failed (GdmSession *session, + const char *message, + GdmFactorySlave *slave) +{ + gdm_greeter_server_problem (slave->priv->greeter_server, _("Unable to authenticate user")); - gdm_greeter_server_reset (slave->priv->greeter_server); + queue_greeter_reset (slave); } -static gboolean -greeter_reset_timeout (GdmFactorySlave *slave) +static void +on_session_authorized (GdmSession *session, + GdmFactorySlave *slave) { - gdm_greeter_server_reset (slave->priv->greeter_server); - slave->priv->greeter_reset_id = 0; - return FALSE; + int flag; + + /* FIXME: check for migration? */ + flag = GDM_SESSION_CRED_ESTABLISH; + + gdm_session_accredit (session, flag); } static void -queue_greeter_reset (GdmFactorySlave *slave) +on_session_authorization_failed (GdmSession *session, + const char *message, + GdmFactorySlave *slave) { - if (slave->priv->greeter_reset_id > 0) { - return; - } + gdm_greeter_server_problem (slave->priv->greeter_server, _("Unable to authorize user")); - slave->priv->greeter_reset_id = g_timeout_add_seconds (2, (GSourceFunc)greeter_reset_timeout, slave); + queue_greeter_reset (slave); +} + +static void +on_session_accredited (GdmSession *session, + GdmFactorySlave *slave) +{ + g_debug ("GdmFactorySlave: session user verified"); + + gdm_session_start_session (session); + + gdm_greeter_server_reset (slave->priv->greeter_server); } static void -on_session_user_verification_error (GdmSession *session, - const char *message, - GdmFactorySlave *slave) +on_session_accreditation_failed (GdmSession *session, + const char *message, + GdmFactorySlave *slave) { g_debug ("GdmFactorySlave: could not successfully authenticate user: %s", message); - gdm_greeter_server_problem (slave->priv->greeter_server, _("Unable to authenticate user")); + gdm_greeter_server_problem (slave->priv->greeter_server, _("Unable to establish credentials")); queue_greeter_reset (slave); } @@ -285,8 +356,7 @@ on_greeter_begin_verification (GdmGreeterServer *greeter_server, GdmFactorySlave *slave) { g_debug ("GdmFactorySlave: begin verification"); - - gdm_session_begin_verification (GDM_SESSION (slave->priv->session)); + gdm_session_setup (GDM_SESSION (slave->priv->session)); } static void @@ -295,9 +365,8 @@ on_greeter_begin_verification_for_user (GdmGreeterServer *greeter_server, GdmFactorySlave *slave) { g_debug ("GdmFactorySlave: begin verification for user"); - - gdm_session_begin_verification_for_user (GDM_SESSION (slave->priv->session), - username); + gdm_session_setup_for_user (GDM_SESSION (slave->priv->session), + username); } static void @@ -552,6 +621,50 @@ gdm_factory_slave_start (GdmSlave *slave) GDM_FACTORY_SLAVE (slave)->priv->session = gdm_session_relay_new (); g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session, + "opened", + G_CALLBACK (on_session_opened), + slave); + g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session, + "setup-complete", + G_CALLBACK (on_session_setup_complete), + slave); + g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session, + "setup-failed", + G_CALLBACK (on_session_setup_failed), + slave); + g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session, + "reset-complete", + G_CALLBACK (on_session_reset_complete), + slave); + g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session, + "reset-failed", + G_CALLBACK (on_session_reset_failed), + slave); + g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session, + "authenticated", + G_CALLBACK (on_session_authenticated), + slave); + g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session, + "authentication-failed", + G_CALLBACK (on_session_authentication_failed), + slave); + g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session, + "authorized", + G_CALLBACK (on_session_authorized), + slave); + g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session, + "authorization-failed", + G_CALLBACK (on_session_authorization_failed), + slave); + g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session, + "accredited", + G_CALLBACK (on_session_accredited), + slave); + g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session, + "accreditation-failed", + G_CALLBACK (on_session_accreditation_failed), + slave); + g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session, "info", G_CALLBACK (on_session_info), slave); @@ -568,18 +681,6 @@ gdm_factory_slave_start (GdmSlave *slave) G_CALLBACK (on_session_secret_info_query), slave); g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session, - "user-verified", - G_CALLBACK (on_session_user_verified), - slave); - g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session, - "user-verification-error", - G_CALLBACK (on_session_user_verification_error), - slave); - g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session, - "opened", - G_CALLBACK (on_session_opened), - slave); - g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session, "session-started", G_CALLBACK (on_session_session_started), slave); diff --git a/daemon/gdm-product-slave.c b/daemon/gdm-product-slave.c index b0c8d162..fb197343 100644 --- a/daemon/gdm-product-slave.c +++ b/daemon/gdm-product-slave.c @@ -378,20 +378,92 @@ gdm_product_slave_create_server (GdmProductSlave *slave) } static void -on_session_user_verified (GdmSession *session, +on_session_setup_complete (GdmSession *session, + GdmProductSlave *slave) +{ + send_dbus_void_method (slave->priv->session_relay_connection, + "SetupComplete"); +} + +static void +on_session_setup_failed (GdmSession *session, + const char *message, + GdmProductSlave *slave) +{ + send_dbus_string_method (slave->priv->session_relay_connection, + "SetupFailed", + message); +} + +static void +on_session_reset_complete (GdmSession *session, + GdmProductSlave *slave) +{ + send_dbus_void_method (slave->priv->session_relay_connection, + "ResetComplete"); +} + +static void +on_session_reset_failed (GdmSession *session, + const char *message, + GdmProductSlave *slave) +{ + send_dbus_string_method (slave->priv->session_relay_connection, + "ResetFailed", + message); +} + +static void +on_session_authenticated (GdmSession *session, GdmProductSlave *slave) { send_dbus_void_method (slave->priv->session_relay_connection, - "UserVerified"); + "Authenticated"); } static void -on_session_user_verification_error (GdmSession *session, - const char *message, - GdmProductSlave *slave) +on_session_authentication_failed (GdmSession *session, + const char *message, + GdmProductSlave *slave) { send_dbus_string_method (slave->priv->session_relay_connection, - "UserVerificationError", + "AuthenticationFailed", + message); +} + +static void +on_session_authorized (GdmSession *session, + GdmProductSlave *slave) +{ + send_dbus_void_method (slave->priv->session_relay_connection, + "Authorized"); +} + +static void +on_session_authorization_failed (GdmSession *session, + const char *message, + GdmProductSlave *slave) +{ + send_dbus_string_method (slave->priv->session_relay_connection, + "AuthorizationFailed", + message); +} + +static void +on_session_accredited (GdmSession *session, + GdmProductSlave *slave) +{ + send_dbus_void_method (slave->priv->session_relay_connection, + "Accredited"); +} + +static void +on_session_accreditation_failed (GdmSession *session, + const char *message, + GdmProductSlave *slave) +{ + send_dbus_string_method (slave->priv->session_relay_connection, + "AccreditationFailed", message); } @@ -436,17 +508,17 @@ on_session_secret_info_query (GdmSession *session, } static void -on_relay_begin_verification (GdmProductSlave *slave, - DBusMessage *message) +on_relay_setup (GdmProductSlave *slave, + DBusMessage *message) { - g_debug ("GdmProductSlave: Relay BeginVerification"); + g_debug ("GdmProductSlave: Relay Setup"); - gdm_session_begin_verification (GDM_SESSION (slave->priv->session)); + gdm_session_setup (GDM_SESSION (slave->priv->session)); } static void -on_relay_begin_verification_for_user (GdmProductSlave *slave, - DBusMessage *message) +on_relay_setup_for_user (GdmProductSlave *slave, + DBusMessage *message) { DBusError error; const char *text; @@ -458,8 +530,8 @@ on_relay_begin_verification_for_user (GdmProductSlave *slave, DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID); if (res) { - g_debug ("GdmProductSlave: Relay BeginVerificationForUser"); - gdm_session_begin_verification_for_user (GDM_SESSION (slave->priv->session), text); + g_debug ("GdmProductSlave: Relay SetupForUser"); + gdm_session_setup_for_user (GDM_SESSION (slave->priv->session), text); } else { g_warning ("Unable to get arguments: %s", error.message); dbus_error_free (&error); @@ -467,6 +539,42 @@ on_relay_begin_verification_for_user (GdmProductSlave *slave, } static void +on_relay_authenticate (GdmProductSlave *slave, + DBusMessage *message) +{ + g_debug ("GdmProductSlave: Relay Authenticate"); + + gdm_session_authenticate (GDM_SESSION (slave->priv->session)); +} + +static void +on_relay_authorize (GdmProductSlave *slave, + DBusMessage *message) +{ + g_debug ("GdmProductSlave: Relay Authorize"); + + gdm_session_authorize (GDM_SESSION (slave->priv->session)); +} + +static void +on_relay_establish_credentials (GdmProductSlave *slave, + DBusMessage *message) +{ + g_debug ("GdmProductSlave: Relay Authorize"); + + gdm_session_accredit (GDM_SESSION (slave->priv->session), GDM_SESSION_CRED_ESTABLISH); +} + +static void +on_relay_renew_credentials (GdmProductSlave *slave, + DBusMessage *message) +{ + g_debug ("GdmProductSlave: Relay Authorize"); + + gdm_session_accredit (GDM_SESSION (slave->priv->session), GDM_SESSION_CRED_RENEW); +} + +static void on_relay_answer_query (GdmProductSlave *slave, DBusMessage *message) { @@ -584,38 +692,65 @@ create_new_session (GdmProductSlave *slave) "opened", G_CALLBACK (on_session_opened), slave); + g_signal_connect (slave->priv->session, + "setup-complete", + G_CALLBACK (on_session_setup_complete), + slave); + g_signal_connect (slave->priv->session, + "setup-failed", + G_CALLBACK (on_session_setup_failed), + slave); + g_signal_connect (slave->priv->session, + "reset-complete", + G_CALLBACK (on_session_reset_complete), + slave); + g_signal_connect (slave->priv->session, + "reset-failed", + G_CALLBACK (on_session_reset_failed), + slave); + g_signal_connect (slave->priv->session, + "authenticated", + G_CALLBACK (on_session_authenticated), + slave); + g_signal_connect (slave->priv->session, + "authentication-failed", + G_CALLBACK (on_session_authentication_failed), + slave); + g_signal_connect (slave->priv->session, + "authorized", + G_CALLBACK (on_session_authorized), + slave); + g_signal_connect (slave->priv->session, + "authorization-failed", + G_CALLBACK (on_session_authorization_failed), + slave); + g_signal_connect (slave->priv->session, + "accredited", + G_CALLBACK (on_session_accredited), + slave); + g_signal_connect (slave->priv->session, + "accreditation-failed", + G_CALLBACK (on_session_accreditation_failed), + slave); g_signal_connect (slave->priv->session, "info", G_CALLBACK (on_session_info), slave); - g_signal_connect (slave->priv->session, "problem", G_CALLBACK (on_session_problem), slave); - g_signal_connect (slave->priv->session, "info-query", G_CALLBACK (on_session_info_query), slave); - g_signal_connect (slave->priv->session, "secret-info-query", G_CALLBACK (on_session_secret_info_query), slave); g_signal_connect (slave->priv->session, - "user-verified", - G_CALLBACK (on_session_user_verified), - slave); - - g_signal_connect (slave->priv->session, - "user-verification-error", - G_CALLBACK (on_session_user_verification_error), - slave); - - g_signal_connect (slave->priv->session, "session-started", G_CALLBACK (on_session_started), slave); @@ -689,12 +824,18 @@ relay_dbus_handle_message (DBusConnection *connection, g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED); g_return_val_if_fail (message != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED); - if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "BeginVerification")) { - on_relay_begin_verification (slave, message); - } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "BeginVerificationForUser")) { - on_relay_begin_verification_for_user (slave, message); - } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "BeginVerificationForUser")) { - on_relay_begin_verification_for_user (slave, message); + if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "Setup")) { + on_relay_setup (slave, message); + } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "SetupForUser")) { + on_relay_setup_for_user (slave, message); + } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "Authenticate")) { + on_relay_authenticate (slave, message); + } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "Authorize")) { + on_relay_authorize (slave, message); + } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "EstablishCredentials")) { + on_relay_establish_credentials (slave, message); + } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "RenewCredentials")) { + on_relay_renew_credentials (slave, message); } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "AnswerQuery")) { on_relay_answer_query (slave, message); } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "SessionSelected")) { diff --git a/daemon/gdm-session-direct.c b/daemon/gdm-session-direct.c index dbea510f..1247592d 100644 --- a/daemon/gdm-session-direct.c +++ b/daemon/gdm-session-direct.c @@ -74,7 +74,7 @@ struct _GdmSessionDirectPrivate GdmSessionWorkerJob *job; GPid session_pid; - guint32 is_verified : 1; + guint32 is_authenticated : 1; guint32 is_running : 1; /* object lifetime scope */ @@ -106,17 +106,6 @@ G_DEFINE_TYPE_WITH_CODE (GdmSessionDirect, G_IMPLEMENT_INTERFACE (GDM_TYPE_SESSION, gdm_session_iface_init)); -GQuark -gdm_session_direct_error_quark (void) -{ - static GQuark error_quark = 0; - - if (error_quark == 0) - error_quark = g_quark_from_static_string ("gdm-session-direct"); - - return error_quark; -} - static gboolean send_dbus_message (DBusConnection *connection, DBusMessage *message) @@ -167,8 +156,27 @@ send_dbus_string_signal (GdmSessionDirect *session, } static void -on_user_verification_error (GdmSession *session, - const char *message) +send_dbus_void_signal (GdmSessionDirect *session, + const char *name) +{ + DBusMessage *message; + + g_return_if_fail (session != NULL); + + message = dbus_message_new_signal (GDM_SESSION_DBUS_PATH, + GDM_SESSION_DBUS_INTERFACE, + name); + + if (! send_dbus_message (session->priv->worker_connection, message)) { + g_debug ("GdmSessionDirect: Could not send %s signal", name); + } + + dbus_message_unref (message); +} + +static void +on_authentication_failed (GdmSession *session, + const char *message) { GdmSessionDirect *impl = GDM_SESSION_DIRECT (session); gdm_session_record_failed (impl->priv->session_pid, @@ -190,8 +198,8 @@ on_session_started (GdmSession *session) } static void -on_session_startup_error (GdmSession *session, - const char *message) +on_session_start_failed (GdmSession *session, + const char *message) { GdmSessionDirect *impl = GDM_SESSION_DIRECT (session); gdm_session_record_login (impl->priv->session_pid, @@ -214,29 +222,118 @@ on_session_exited (GdmSession *session, } static DBusHandlerResult -gdm_session_direct_handle_verified (GdmSessionDirect *session, - DBusConnection *connection, - DBusMessage *message) +gdm_session_direct_handle_setup_complete (GdmSessionDirect *session, + DBusConnection *connection, + DBusMessage *message) +{ + DBusMessage *reply; + + g_debug ("GdmSessionDirect: Emitting 'setup-complete' signal"); + + reply = dbus_message_new_method_return (message); + dbus_connection_send (connection, reply, NULL); + dbus_message_unref (reply); + + _gdm_session_setup_complete (GDM_SESSION (session)); + + return DBUS_HANDLER_RESULT_HANDLED; +} + +static DBusHandlerResult +gdm_session_direct_handle_setup_failed (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: Emitting 'setup-failed' signal"); + + _gdm_session_setup_failed (GDM_SESSION (session), NULL); + + return DBUS_HANDLER_RESULT_HANDLED; +} + + +static DBusHandlerResult +gdm_session_direct_handle_reset_complete (GdmSessionDirect *session, + DBusConnection *connection, + DBusMessage *message) +{ + DBusMessage *reply; + + g_debug ("GdmSessionDirect: Emitting 'reset-complete' signal"); + + reply = dbus_message_new_method_return (message); + dbus_connection_send (connection, reply, NULL); + dbus_message_unref (reply); + + _gdm_session_reset_complete (GDM_SESSION (session)); + + return DBUS_HANDLER_RESULT_HANDLED; +} + +static DBusHandlerResult +gdm_session_direct_handle_reset_failed (GdmSessionDirect *session, + DBusConnection *connection, + DBusMessage *message) { DBusMessage *reply; + DBusError error; + const char *text; - g_debug ("GdmSessionDirect: Emitting 'user-verified' signal"); + 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); - session->priv->is_verified = TRUE; + g_debug ("GdmSessionDirect: Emitting 'reset-failed' signal"); + + _gdm_session_reset_failed (GDM_SESSION (session), NULL); + + return DBUS_HANDLER_RESULT_HANDLED; +} + +static DBusHandlerResult +gdm_session_direct_handle_authenticated (GdmSessionDirect *session, + DBusConnection *connection, + DBusMessage *message) +{ + DBusMessage *reply; - _gdm_session_user_verified (GDM_SESSION (session)); + g_debug ("GdmSessionDirect: Emitting 'authenticated' signal"); + + reply = dbus_message_new_method_return (message); + dbus_connection_send (connection, reply, NULL); + dbus_message_unref (reply); + + _gdm_session_authenticated (GDM_SESSION (session)); return DBUS_HANDLER_RESULT_HANDLED; } static DBusHandlerResult -gdm_session_direct_handle_verification_failed (GdmSessionDirect *session, - DBusConnection *connection, - DBusMessage *message) +gdm_session_direct_handle_authentication_failed (GdmSessionDirect *session, + DBusConnection *connection, + DBusMessage *message) { DBusMessage *reply; DBusError error; @@ -253,9 +350,99 @@ gdm_session_direct_handle_verification_failed (GdmSessionDirect *session, dbus_connection_send (connection, reply, NULL); dbus_message_unref (reply); - g_debug ("GdmSessionDirect: Emitting 'verification-failed' signal"); + g_debug ("GdmSessionDirect: Emitting 'authentication-failed' signal"); + + _gdm_session_authentication_failed (GDM_SESSION (session), NULL); + + return DBUS_HANDLER_RESULT_HANDLED; +} + +static DBusHandlerResult +gdm_session_direct_handle_authorized (GdmSessionDirect *session, + DBusConnection *connection, + DBusMessage *message) +{ + DBusMessage *reply; - _gdm_session_user_verification_error (GDM_SESSION (session), NULL); + g_debug ("GdmSessionDirect: Emitting 'authorized' signal"); + + reply = dbus_message_new_method_return (message); + dbus_connection_send (connection, reply, NULL); + dbus_message_unref (reply); + + _gdm_session_authorized (GDM_SESSION (session)); + + return DBUS_HANDLER_RESULT_HANDLED; +} + +static DBusHandlerResult +gdm_session_direct_handle_authorization_failed (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: Emitting 'authorization-failed' signal"); + + _gdm_session_authorization_failed (GDM_SESSION (session), NULL); + + return DBUS_HANDLER_RESULT_HANDLED; +} + +static DBusHandlerResult +gdm_session_direct_handle_accredited (GdmSessionDirect *session, + DBusConnection *connection, + DBusMessage *message) +{ + DBusMessage *reply; + + g_debug ("GdmSessionDirect: Emitting 'accredited' signal"); + + reply = dbus_message_new_method_return (message); + dbus_connection_send (connection, reply, NULL); + dbus_message_unref (reply); + + _gdm_session_accredited (GDM_SESSION (session)); + + return DBUS_HANDLER_RESULT_HANDLED; +} + +static DBusHandlerResult +gdm_session_direct_handle_accreditation_failed (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: Emitting 'accreditation-failed' signal"); + + _gdm_session_accreditation_failed (GDM_SESSION (session), NULL); return DBUS_HANDLER_RESULT_HANDLED; } @@ -473,9 +660,9 @@ gdm_session_direct_handle_session_started (GdmSessionDirect *session, } static DBusHandlerResult -gdm_session_direct_handle_startup_failed (GdmSessionDirect *session, - DBusConnection *connection, - DBusMessage *message) +gdm_session_direct_handle_start_failed (GdmSessionDirect *session, + DBusConnection *connection, + DBusMessage *message) { DBusMessage *reply; DBusError error; @@ -492,8 +679,8 @@ gdm_session_direct_handle_startup_failed (GdmSessionDirect *session, dbus_connection_send (connection, reply, NULL); dbus_message_unref (reply); - g_debug ("GdmSessionDirect: Emitting 'session-startup-error' signal"); - _gdm_session_session_startup_error (GDM_SESSION (session), text); + g_debug ("GdmSessionDirect: Emitting 'session-start-failed' signal"); + _gdm_session_session_start_failed (GDM_SESSION (session), text); return DBUS_HANDLER_RESULT_HANDLED; } @@ -563,13 +750,7 @@ session_worker_message (DBusConnection *connection, { GdmSessionDirect *session = GDM_SESSION_DIRECT (user_data); - if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "Verified")) { - return gdm_session_direct_handle_verified (session, connection, message); - } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "VerificationFailed")) { - return gdm_session_direct_handle_verification_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, "InfoQuery")) { + if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "InfoQuery")) { return gdm_session_direct_handle_info_query (session, connection, message); } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "SecretInfoQuery")) { return gdm_session_direct_handle_secret_info_query (session, connection, message); @@ -577,10 +758,32 @@ session_worker_message (DBusConnection *connection, return gdm_session_direct_handle_info (session, connection, message); } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "Problem")) { return gdm_session_direct_handle_problem (session, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "SetupComplete")) { + return gdm_session_direct_handle_setup_complete (session, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "SetupFailed")) { + return gdm_session_direct_handle_setup_failed (session, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "ResetComplete")) { + return gdm_session_direct_handle_reset_complete (session, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "ResetFailed")) { + return gdm_session_direct_handle_reset_failed (session, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "Authenticated")) { + return gdm_session_direct_handle_authenticated (session, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "AuthenticationFailed")) { + return gdm_session_direct_handle_authentication_failed (session, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "Authorized")) { + return gdm_session_direct_handle_authorized (session, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "AuthorizationFailed")) { + return gdm_session_direct_handle_authorization_failed (session, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "Accredited")) { + return gdm_session_direct_handle_accredited (session, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "AccreditationFailed")) { + 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, "SessionStarted")) { return gdm_session_direct_handle_session_started (session, connection, message); - } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "StartupFailed")) { - return gdm_session_direct_handle_startup_failed (session, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "StartFailed")) { + return gdm_session_direct_handle_start_failed (session, connection, message); } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "SessionExited")) { return gdm_session_direct_handle_session_exited (session, connection, message); } else if (dbus_message_is_method_call (message, GDM_SESSION_DBUS_INTERFACE, "SessionDied")) { @@ -613,9 +816,29 @@ do_introspect (DBusConnection *connection, /* interface */ xml = g_string_append (xml, " <interface name=\"org.gnome.DisplayManager.Session\">\n" - " <method name=\"Verified\">\n" + " <method name=\"SetupComplete\">\n" + " </method>\n" + " <method name=\"SetupFailed\">\n" + " <arg name=\"message\" direction=\"in\" type=\"s\"/>\n" + " </method>\n" + " <method name=\"ResetComplete\">\n" + " </method>\n" + " <method name=\"ResetFailed\">\n" + " <arg name=\"message\" direction=\"in\" type=\"s\"/>\n" + " </method>\n" + " <method name=\"Authenticated\">\n" + " </method>\n" + " <method name=\"AuthenticationFailed\">\n" + " <arg name=\"message\" direction=\"in\" type=\"s\"/>\n" + " </method>\n" + " <method name=\"Authorized\">\n" + " </method>\n" + " <method name=\"AuthorizationFailed\">\n" + " <arg name=\"message\" direction=\"in\" type=\"s\"/>\n" + " </method>\n" + " <method name=\"Accredited\">\n" " </method>\n" - " <method name=\"VerificationFailed\">\n" + " <method name=\"AccreditationFailed\">\n" " <arg name=\"message\" direction=\"in\" type=\"s\"/>\n" " </method>\n" " <method name=\"InfoQuery\">\n" @@ -635,7 +858,7 @@ do_introspect (DBusConnection *connection, " <method name=\"UsernameChanged\">\n" " <arg name=\"text\" direction=\"in\" type=\"s\"/>\n" " </method>\n" - " <method name=\"StartupFailed\">\n" + " <method name=\"StartFailed\">\n" " <arg name=\"message\" direction=\"in\" type=\"s\"/>\n" " </method>\n" " <method name=\"SessionStarted\">\n" @@ -647,27 +870,35 @@ do_introspect (DBusConnection *connection, " <method name=\"SessionDied\">\n" " <arg name=\"signal\" direction=\"in\" type=\"i\"/>\n" " </method>\n" - " <signal name=\"BeginVerification\">\n" + " <signal name=\"Reset\">\n" + " </signal>\n" + " <signal name=\"Setup\">\n" " <arg name=\"service_name\" type=\"s\"/>\n" " <arg name=\"x11_display_name\" type=\"s\"/>\n" " <arg name=\"display_device\" type=\"s\"/>\n" " <arg name=\"hostname\" type=\"s\"/>\n" " </signal>\n" - " <signal name=\"BeginVerificationForUser\">\n" + " <signal name=\"SetupForUser\">\n" " <arg name=\"service_name\" type=\"s\"/>\n" " <arg name=\"x11_display_name\" type=\"s\"/>\n" " <arg name=\"display_device\" type=\"s\"/>\n" " <arg name=\"hostname\" type=\"s\"/>\n" " <arg name=\"username\" type=\"s\"/>\n" " </signal>\n" - " <signal name=\"StartProgram\">\n" - " <arg name=\"command\" type=\"s\"/>\n" + " <signal name=\"Authenticate\">\n" + " </signal>\n" + " <signal name=\"Authorize\">\n" + " </signal>\n" + " <signal name=\"EstablishCredentials\">\n" + " </signal>\n" + " <signal name=\"RenewCredentials\">\n" " </signal>\n" " <signal name=\"SetEnvironmentVariable\">\n" " <arg name=\"name\" type=\"s\"/>\n" " <arg name=\"value\" type=\"s\"/>\n" " </signal>\n" - " <signal name=\"Reset\">\n" + " <signal name=\"StartProgram\">\n" + " <arg name=\"command\" type=\"s\"/>\n" " </signal>\n" " </interface>\n"); @@ -882,16 +1113,16 @@ gdm_session_direct_init (GdmSessionDirect *session) GdmSessionDirectPrivate); g_signal_connect (session, - "user-verification-error", - G_CALLBACK (on_user_verification_error), + "authentication-failed", + G_CALLBACK (on_authentication_failed), NULL); g_signal_connect (session, "session-started", G_CALLBACK (on_session_started), NULL); g_signal_connect (session, - "session-startup-error", - G_CALLBACK (on_session_startup_error), + "session-start-failed", + G_CALLBACK (on_session_start_failed), NULL); g_signal_connect (session, "session-exited", @@ -936,11 +1167,11 @@ worker_exited (GdmSessionWorkerJob *job, { g_debug ("GdmSessionDirect: Worker job exited: %d", code); - if (!session->priv->is_verified) { + if (!session->priv->is_authenticated) { char *msg; msg = g_strdup_printf (_("worker exited with status %d"), code); - _gdm_session_user_verification_error (GDM_SESSION (session), msg); + _gdm_session_authentication_failed (GDM_SESSION (session), msg); g_free (msg); } else if (session->priv->is_running) { _gdm_session_session_exited (GDM_SESSION (session), code); @@ -954,11 +1185,11 @@ worker_died (GdmSessionWorkerJob *job, { g_debug ("GdmSessionDirect: Worker job died: %d", signum); - if (!session->priv->is_verified) { + if (!session->priv->is_authenticated) { char *msg; msg = g_strdup_printf (_("worker exited with status %d"), signum); - _gdm_session_user_verification_error (GDM_SESSION (session), msg); + _gdm_session_authentication_failed (GDM_SESSION (session), msg); g_free (msg); } else if (session->priv->is_running) { _gdm_session_session_died (GDM_SESSION (session), signum); @@ -1016,13 +1247,13 @@ gdm_session_direct_open (GdmSession *session) g_return_if_fail (session != NULL); - g_debug ("GdmSessionDirect: Openning session"); + g_debug ("GdmSessionDirect: Opening session"); res = start_worker (impl); } static void -send_begin_verification (GdmSessionDirect *session) +send_setup (GdmSessionDirect *session) { DBusMessage *message; DBusMessageIter iter; @@ -1046,11 +1277,11 @@ send_begin_verification (GdmSessionDirect *session) display_device = ""; } - g_debug ("GdmSessionDirect: Beginning verification"); + g_debug ("GdmSessionDirect: Beginning setup"); message = dbus_message_new_signal (GDM_SESSION_DBUS_PATH, GDM_SESSION_DBUS_INTERFACE, - "BeginVerification"); + "Setup"); dbus_message_iter_init_append (message, &iter); dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session->priv->service_name); @@ -1059,14 +1290,14 @@ send_begin_verification (GdmSessionDirect *session) dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &display_hostname); if (! send_dbus_message (session->priv->worker_connection, message)) { - g_debug ("GdmSessionDirect: Could not send %s signal", "BeginVerification"); + g_debug ("GdmSessionDirect: Could not send %s signal", "Setup"); } dbus_message_unref (message); } static void -send_begin_verification_for_user (GdmSessionDirect *session) +send_setup_for_user (GdmSessionDirect *session) { DBusMessage *message; DBusMessageIter iter; @@ -1096,11 +1327,11 @@ send_begin_verification_for_user (GdmSessionDirect *session) selected_user = ""; } - g_debug ("GdmSessionDirect: Beginning verification for user %s", session->priv->selected_user); + g_debug ("GdmSessionDirect: Beginning setup for user %s", session->priv->selected_user); message = dbus_message_new_signal (GDM_SESSION_DBUS_PATH, GDM_SESSION_DBUS_INTERFACE, - "BeginVerificationForUser"); + "SetupForUser"); dbus_message_iter_init_append (message, &iter); dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session->priv->service_name); @@ -1110,26 +1341,26 @@ send_begin_verification_for_user (GdmSessionDirect *session) dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &selected_user); if (! send_dbus_message (session->priv->worker_connection, message)) { - g_debug ("GdmSessionDirect: Could not send %s signal", "BeginVerificationForUser"); + g_debug ("GdmSessionDirect: Could not send %s signal", "SetupForUser"); } dbus_message_unref (message); } static void -gdm_session_direct_begin_verification (GdmSession *session) +gdm_session_direct_setup (GdmSession *session) { GdmSessionDirect *impl = GDM_SESSION_DIRECT (session); g_return_if_fail (session != NULL); g_return_if_fail (dbus_connection_get_is_connected (impl->priv->worker_connection)); - send_begin_verification (impl); + send_setup (impl); } static void -gdm_session_direct_begin_verification_for_user (GdmSession *session, - const char *username) +gdm_session_direct_setup_for_user (GdmSession *session, + const char *username) { GdmSessionDirect *impl = GDM_SESSION_DIRECT (session); @@ -1139,7 +1370,50 @@ gdm_session_direct_begin_verification_for_user (GdmSession *session, impl->priv->selected_user = g_strdup (username); - send_begin_verification_for_user (impl); + send_setup_for_user (impl); +} + +static void +gdm_session_direct_authenticate (GdmSession *session) +{ + GdmSessionDirect *impl = GDM_SESSION_DIRECT (session); + + g_return_if_fail (session != NULL); + g_return_if_fail (dbus_connection_get_is_connected (impl->priv->worker_connection)); + + send_dbus_void_signal (impl, "Authenticate"); +} + +static void +gdm_session_direct_authorize (GdmSession *session) +{ + GdmSessionDirect *impl = GDM_SESSION_DIRECT (session); + + g_return_if_fail (session != NULL); + g_return_if_fail (dbus_connection_get_is_connected (impl->priv->worker_connection)); + + send_dbus_void_signal (impl, "Authorize"); +} + +static void +gdm_session_direct_accredit (GdmSession *session, + int cred_flag) +{ + GdmSessionDirect *impl = GDM_SESSION_DIRECT (session); + + g_return_if_fail (session != NULL); + g_return_if_fail (dbus_connection_get_is_connected (impl->priv->worker_connection)); + + switch (cred_flag) { + case GDM_SESSION_CRED_ESTABLISH: + send_dbus_void_signal (impl, "EstablishCredentials"); + break; + case GDM_SESSION_CRED_RENEW: + send_dbus_void_signal (impl, "RenewCredentials"); + break; + default: + g_assert_not_reached (); + } } static void @@ -1473,9 +1747,6 @@ gdm_session_direct_close (GdmSession *session) stop_worker (impl); } - impl->priv->is_running = FALSE; - impl->priv->is_verified = FALSE; - g_free (impl->priv->selected_user); impl->priv->selected_user = NULL; @@ -1491,7 +1762,7 @@ gdm_session_direct_close (GdmSession *session) g_hash_table_remove_all (impl->priv->environment); impl->priv->session_pid = -1; - impl->priv->is_verified = FALSE; + impl->priv->is_authenticated = FALSE; impl->priv->is_running = FALSE; } @@ -1719,10 +1990,14 @@ gdm_session_direct_finalize (GObject *object) static void gdm_session_iface_init (GdmSessionIface *iface) { - iface->begin_verification = gdm_session_direct_begin_verification; - iface->begin_verification_for_user = gdm_session_direct_begin_verification_for_user; iface->open = gdm_session_direct_open; + iface->setup = gdm_session_direct_setup; + iface->setup_for_user = gdm_session_direct_setup_for_user; + iface->authenticate = gdm_session_direct_authenticate; + iface->authorize = gdm_session_direct_authorize; + iface->accredit = gdm_session_direct_accredit; iface->close = gdm_session_direct_close; + iface->cancel = gdm_session_direct_cancel; iface->start_session = gdm_session_direct_start_session; iface->answer_query = gdm_session_direct_answer_query; diff --git a/daemon/gdm-session-direct.h b/daemon/gdm-session-direct.h index 51083789..94ba1f2a 100644 --- a/daemon/gdm-session-direct.h +++ b/daemon/gdm-session-direct.h @@ -32,7 +32,6 @@ G_BEGIN_DECLS #define GDM_IS_SESSION_DIRECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDM_TYPE_SESSION_DIRECT)) #define GDM_IS_SESSION_DIRECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDM_TYPE_SESSION_DIRECT)) #define GDM_SESSION_DIRECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GDM_TYPE_SESSION_DIRECT, GdmSessionDirectClass)) -#define GDM_SESSION_DIRECT_ERROR (gdm_session_direct_error_quark ()) typedef struct _GdmSessionDirectPrivate GdmSessionDirectPrivate; @@ -47,21 +46,7 @@ typedef struct GObjectClass parent_class; } GdmSessionDirectClass; -typedef enum _GdmSessionDirectError { - GDM_SESSION_DIRECT_ERROR_GENERIC = 0, - GDM_SESSION_DIRECT_ERROR_WITH_SESSION_DIRECT_COMMAND, - GDM_SESSION_DIRECT_ERROR_FORKING, - GDM_SESSION_DIRECT_ERROR_COMMUNICATING, - GDM_SESSION_DIRECT_ERROR_WORKER_DIED, - GDM_SESSION_DIRECT_ERROR_AUTHENTICATING, - GDM_SESSION_DIRECT_ERROR_AUTHORIZING, - GDM_SESSION_DIRECT_ERROR_OPENING_LOG_FILE, - GDM_SESSION_DIRECT_ERROR_OPENING_SESSION_DIRECT, - GDM_SESSION_DIRECT_ERROR_GIVING_CREDENTIALS -} GdmSessionDirectError; - GType gdm_session_direct_get_type (void); -GQuark gdm_session_direct_error_quark (void); GdmSessionDirect * gdm_session_direct_new (const char *display_name, const char *display_hostname, diff --git a/daemon/gdm-session-private.h b/daemon/gdm-session-private.h index caa2331d..af22f14b 100644 --- a/daemon/gdm-session-private.h +++ b/daemon/gdm-session-private.h @@ -26,40 +26,47 @@ G_BEGIN_DECLS -void _gdm_session_user_verified (GdmSession *session); - -void _gdm_session_user_verification_error (GdmSession *session, - const char *text); - -void _gdm_session_info_query (GdmSession *session, - const char *text); - -void _gdm_session_secret_info_query (GdmSession *session, +/* state changes */ +void _gdm_session_opened (GdmSession *session); +void _gdm_session_setup_complete (GdmSession *session); +void _gdm_session_setup_failed (GdmSession *session, + const char *message); +void _gdm_session_reset_complete (GdmSession *session); +void _gdm_session_reset_failed (GdmSession *session, + const char *message); +void _gdm_session_authenticated (GdmSession *session); +void _gdm_session_authentication_failed (GdmSession *session, const char *text); - -void _gdm_session_info (GdmSession *session, +void _gdm_session_authorized (GdmSession *session); +void _gdm_session_authorization_failed (GdmSession *session, const char *text); - -void _gdm_session_problem (GdmSession *session, +void _gdm_session_accredited (GdmSession *session); +void _gdm_session_accreditation_failed (GdmSession *session, const char *text); - void _gdm_session_session_started (GdmSession *session); - -void _gdm_session_session_startup_error (GdmSession *session, +void _gdm_session_session_start_failed (GdmSession *session, const char *message); - void _gdm_session_session_exited (GdmSession *session, int exit_code); - void _gdm_session_session_died (GdmSession *session, int signal_number); - -void _gdm_session_opened (GdmSession *session); void _gdm_session_closed (GdmSession *session); + +/* user is selected/changed internally */ void _gdm_session_selected_user_changed (GdmSession *session, const char *text); +/* call and response stuff */ +void _gdm_session_info_query (GdmSession *session, + const char *text); +void _gdm_session_secret_info_query (GdmSession *session, + const char *text); +void _gdm_session_info (GdmSession *session, + const char *text); +void _gdm_session_problem (GdmSession *session, + const char *text); + G_END_DECLS #endif /* __GDM_SESSION_PRIVATE_H */ diff --git a/daemon/gdm-session-relay.c b/daemon/gdm-session-relay.c index 59c84825..cda094d8 100644 --- a/daemon/gdm-session-relay.c +++ b/daemon/gdm-session-relay.c @@ -116,6 +116,7 @@ send_dbus_string_signal (GdmSessionRelay *session_relay, g_return_if_fail (session_relay != NULL); + g_debug ("GdmSessionRelay: sending signal %s", name); message = dbus_message_new_signal (GDM_SESSION_RELAY_DBUS_PATH, GDM_SESSION_RELAY_DBUS_INTERFACE, name); @@ -138,6 +139,7 @@ send_dbus_void_signal (GdmSessionRelay *session_relay, g_return_if_fail (session_relay != NULL); + g_debug ("GdmSessionRelay: sending signal %s", name); message = dbus_message_new_signal (GDM_SESSION_RELAY_DBUS_PATH, GDM_SESSION_RELAY_DBUS_INTERFACE, name); @@ -164,20 +166,50 @@ gdm_session_relay_close (GdmSession *session) } static void -gdm_session_relay_begin_verification (GdmSession *session) +gdm_session_relay_setup (GdmSession *session) { GdmSessionRelay *impl = GDM_SESSION_RELAY (session); - g_debug ("GdmSessionRelay: Sending signal BeginVerification"); - send_dbus_void_signal (impl, "BeginVerification"); + send_dbus_void_signal (impl, "Setup"); } static void -gdm_session_relay_begin_verification_for_user (GdmSession *session, - const char *username) +gdm_session_relay_setup_for_user (GdmSession *session, + const char *username) { GdmSessionRelay *impl = GDM_SESSION_RELAY (session); - g_debug ("GdmSessionRelay: Sending signal BeginVerificationForUser"); - send_dbus_string_signal (impl, "BeginVerificationForUser", username); + send_dbus_string_signal (impl, "SetupForUser", username); +} + +static void +gdm_session_relay_authenticate (GdmSession *session) +{ + GdmSessionRelay *impl = GDM_SESSION_RELAY (session); + send_dbus_void_signal (impl, "Authenticate"); +} + +static void +gdm_session_relay_authorize (GdmSession *session) +{ + GdmSessionRelay *impl = GDM_SESSION_RELAY (session); + send_dbus_void_signal (impl, "Authorize"); +} + +static void +gdm_session_relay_accredit (GdmSession *session, + int cred_flag) +{ + GdmSessionRelay *impl = GDM_SESSION_RELAY (session); + + switch (cred_flag) { + case GDM_SESSION_CRED_ESTABLISH: + send_dbus_void_signal (impl, "EstablishCredentials"); + break; + case GDM_SESSION_CRED_RENEW: + send_dbus_void_signal (impl, "RenewCredentials"); + break; + default: + g_assert_not_reached (); + } } static void @@ -185,7 +217,6 @@ gdm_session_relay_answer_query (GdmSession *session, const char *text) { GdmSessionRelay *impl = GDM_SESSION_RELAY (session); - g_debug ("GdmSessionRelay: Sending signal AnswerQuery"); send_dbus_string_signal (impl, "AnswerQuery", text); } @@ -366,7 +397,50 @@ handle_problem (GdmSessionRelay *session_relay, } static DBusHandlerResult -handle_user_verified (GdmSessionRelay *session_relay, +handle_setup_complete (GdmSessionRelay *session_relay, + DBusConnection *connection, + DBusMessage *message) +{ + DBusMessage *reply; + DBusError error; + + dbus_error_init (&error); + + g_debug ("GdmSessionRelay: SetupComplete"); + + reply = dbus_message_new_method_return (message); + dbus_connection_send (connection, reply, NULL); + dbus_message_unref (reply); + + _gdm_session_setup_complete (GDM_SESSION (session_relay)); + + return DBUS_HANDLER_RESULT_HANDLED; +} + +static DBusHandlerResult +handle_setup_failed (GdmSessionRelay *session_relay, + DBusConnection *connection, + DBusMessage *message) +{ + DBusMessage *reply; + DBusError error; + + dbus_error_init (&error); + + g_debug ("GdmSessionRelay: SetupFailed"); + + reply = dbus_message_new_method_return (message); + dbus_connection_send (connection, reply, NULL); + dbus_message_unref (reply); + + _gdm_session_setup_failed (GDM_SESSION (session_relay), NULL); + + return DBUS_HANDLER_RESULT_HANDLED; +} + + +static DBusHandlerResult +handle_authenticated (GdmSessionRelay *session_relay, DBusConnection *connection, DBusMessage *message) { @@ -375,127 +449,188 @@ handle_user_verified (GdmSessionRelay *session_relay, dbus_error_init (&error); - g_debug ("GdmSessionRelay: UserVerified"); + g_debug ("GdmSessionRelay: Authenticated"); reply = dbus_message_new_method_return (message); dbus_connection_send (connection, reply, NULL); dbus_message_unref (reply); - _gdm_session_user_verified (GDM_SESSION (session_relay)); + _gdm_session_authenticated (GDM_SESSION (session_relay)); return DBUS_HANDLER_RESULT_HANDLED; } static DBusHandlerResult -handle_user_verification_error (GdmSessionRelay *session_relay, - DBusConnection *connection, - DBusMessage *message) +handle_authentication_failed (GdmSessionRelay *session_relay, + DBusConnection *connection, + DBusMessage *message) { DBusMessage *reply; DBusError error; dbus_error_init (&error); - g_debug ("GdmSessionRelay: UserVerificationError"); + g_debug ("GdmSessionRelay: AuthenticationFailed"); reply = dbus_message_new_method_return (message); dbus_connection_send (connection, reply, NULL); dbus_message_unref (reply); - _gdm_session_user_verification_error (GDM_SESSION (session_relay), NULL); + _gdm_session_authentication_failed (GDM_SESSION (session_relay), NULL); return DBUS_HANDLER_RESULT_HANDLED; } static DBusHandlerResult -handle_session_started (GdmSessionRelay *session_relay, - DBusConnection *connection, - DBusMessage *message) +handle_authorized (GdmSessionRelay *session_relay, + DBusConnection *connection, + DBusMessage *message) { DBusMessage *reply; DBusError error; dbus_error_init (&error); - g_debug ("GdmSessionRelay: SessionStarted"); + g_debug ("GdmSessionRelay: Authorized"); reply = dbus_message_new_method_return (message); dbus_connection_send (connection, reply, NULL); dbus_message_unref (reply); - _gdm_session_session_started (GDM_SESSION (session_relay)); + _gdm_session_authorized (GDM_SESSION (session_relay)); return DBUS_HANDLER_RESULT_HANDLED; } static DBusHandlerResult -handle_session_stopped (GdmSessionRelay *session_relay, - DBusConnection *connection, - DBusMessage *message) +handle_authorization_failed (GdmSessionRelay *session_relay, + DBusConnection *connection, + DBusMessage *message) { DBusMessage *reply; DBusError error; dbus_error_init (&error); - g_debug ("GdmSessionRelay: SessionStopped"); + g_debug ("GdmSessionRelay: AuthorizationFailed"); reply = dbus_message_new_method_return (message); dbus_connection_send (connection, reply, NULL); dbus_message_unref (reply); -#if 0 - _gdm_session_session_stopped (GDM_SESSION (session_relay)); -#endif + _gdm_session_authorization_failed (GDM_SESSION (session_relay), NULL); return DBUS_HANDLER_RESULT_HANDLED; } static DBusHandlerResult -handle_opened (GdmSessionRelay *session_relay, - DBusConnection *connection, - DBusMessage *message) +handle_accredited (GdmSessionRelay *session_relay, + DBusConnection *connection, + DBusMessage *message) { DBusMessage *reply; DBusError error; dbus_error_init (&error); - g_debug ("GdmSessionRelay: Opened"); + g_debug ("GdmSessionRelay: Accredited"); reply = dbus_message_new_method_return (message); dbus_connection_send (connection, reply, NULL); dbus_message_unref (reply); - _gdm_session_opened (GDM_SESSION (session_relay)); + _gdm_session_accredited (GDM_SESSION (session_relay)); + + return DBUS_HANDLER_RESULT_HANDLED; +} + +static DBusHandlerResult +handle_accreditation_failed (GdmSessionRelay *session_relay, + DBusConnection *connection, + DBusMessage *message) +{ + DBusMessage *reply; + DBusError error; + + dbus_error_init (&error); + + g_debug ("GdmSessionRelay: AccreditationFailed"); + + reply = dbus_message_new_method_return (message); + dbus_connection_send (connection, reply, NULL); + dbus_message_unref (reply); + + _gdm_session_accreditation_failed (GDM_SESSION (session_relay), NULL); return DBUS_HANDLER_RESULT_HANDLED; } static DBusHandlerResult -handle_reset (GdmSessionRelay *session_relay, - DBusConnection *connection, - DBusMessage *message) +handle_session_started (GdmSessionRelay *session_relay, + DBusConnection *connection, + DBusMessage *message) { DBusMessage *reply; DBusError error; dbus_error_init (&error); - g_debug ("GdmSessionRelay: Reset"); + g_debug ("GdmSessionRelay: SessionStarted"); + + reply = dbus_message_new_method_return (message); + dbus_connection_send (connection, reply, NULL); + dbus_message_unref (reply); + + _gdm_session_session_started (GDM_SESSION (session_relay)); + + return DBUS_HANDLER_RESULT_HANDLED; +} + +static DBusHandlerResult +handle_session_stopped (GdmSessionRelay *session_relay, + DBusConnection *connection, + DBusMessage *message) +{ + DBusMessage *reply; + DBusError error; + + dbus_error_init (&error); + + g_debug ("GdmSessionRelay: SessionStopped"); reply = dbus_message_new_method_return (message); dbus_connection_send (connection, reply, NULL); dbus_message_unref (reply); #if 0 - _gdm_session_reset (GDM_SESSION (session_relay)); + _gdm_session_session_stopped (GDM_SESSION (session_relay)); #endif return DBUS_HANDLER_RESULT_HANDLED; } static DBusHandlerResult +handle_opened (GdmSessionRelay *session_relay, + DBusConnection *connection, + DBusMessage *message) +{ + DBusMessage *reply; + DBusError error; + + dbus_error_init (&error); + + g_debug ("GdmSessionRelay: Opened"); + + reply = dbus_message_new_method_return (message); + dbus_connection_send (connection, reply, NULL); + dbus_message_unref (reply); + + _gdm_session_opened (GDM_SESSION (session_relay)); + + return DBUS_HANDLER_RESULT_HANDLED; +} + +static DBusHandlerResult session_handle_child_message (DBusConnection *connection, DBusMessage *message, void *user_data) @@ -510,18 +645,28 @@ session_handle_child_message (DBusConnection *connection, return handle_info (session_relay, connection, message); } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "Problem")) { return handle_problem (session_relay, connection, message); - } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "UserVerified")) { - return handle_user_verified (session_relay, connection, message); - } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "UserVerificationError")) { - return handle_user_verification_error (session_relay, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "SetupComplete")) { + return handle_setup_complete (session_relay, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "SetupFailed")) { + return handle_setup_failed (session_relay, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "Authenticated")) { + return handle_authenticated (session_relay, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "AuthenticationFailed")) { + return handle_authentication_failed (session_relay, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "Authorized")) { + return handle_authorized (session_relay, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "AuthorizationFailed")) { + return handle_authorization_failed (session_relay, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "Accredited")) { + return handle_accredited (session_relay, connection, message); + } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "AccreditationFailed")) { + return handle_accreditation_failed (session_relay, connection, message); } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "SessionStarted")) { return handle_session_started (session_relay, connection, message); } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "SessionStopped")) { return handle_session_stopped (session_relay, connection, message); } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "Opened")) { return handle_opened (session_relay, connection, message); - } else if (dbus_message_is_method_call (message, GDM_SESSION_RELAY_DBUS_INTERFACE, "Reset")) { - return handle_reset (session_relay, connection, message); } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; @@ -550,10 +695,32 @@ do_introspect (DBusConnection *connection, /* interface */ xml = g_string_append (xml, " <interface name=\"org.gnome.DisplayManager.SessionRelay\">\n" - " <method name=\"UserVerified\">\n" + " <method name=\"Opened\">\n" " </method>\n" - " <method name=\"UserVerificationError\">\n" - " <arg name=\"text\" type=\"s\"/>\n" + " <method name=\"SetupComplete\">\n" + " </method>\n" + " <method name=\"SetupFailed\">\n" + " <arg name=\"message\" direction=\"in\" type=\"s\"/>\n" + " </method>\n" + " <method name=\"ResetComplete\">\n" + " </method>\n" + " <method name=\"RestFailed\">\n" + " <arg name=\"message\" direction=\"in\" type=\"s\"/>\n" + " </method>\n" + " <method name=\"Authenticated\">\n" + " </method>\n" + " <method name=\"AuthenticationFailed\">\n" + " <arg name=\"message\" direction=\"in\" type=\"s\"/>\n" + " </method>\n" + " <method name=\"Authorized\">\n" + " </method>\n" + " <method name=\"AuthorizationFailed\">\n" + " <arg name=\"message\" direction=\"in\" type=\"s\"/>\n" + " </method>\n" + " <method name=\"Accredited\">\n" + " </method>\n" + " <method name=\"AccreditationFailed\">\n" + " <arg name=\"message\" direction=\"in\" type=\"s\"/>\n" " </method>\n" " <method name=\"InfoQuery\">\n" " <arg name=\"text\" type=\"s\"/>\n" @@ -571,19 +738,36 @@ do_introspect (DBusConnection *connection, " </method>\n" " <method name=\"SessionStopped\">\n" " </method>\n" - " <method name=\"Opened\">\n" - " </method>\n" - " <method name=\"Reset\">\n" - " </method>\n" + " <signal name=\"Reset\">\n" + " </signal>\n" + " <signal name=\"Setup\">\n" + " <arg name=\"service_name\" type=\"s\"/>\n" + " <arg name=\"x11_display_name\" type=\"s\"/>\n" + " <arg name=\"display_device\" type=\"s\"/>\n" + " <arg name=\"hostname\" type=\"s\"/>\n" + " </signal>\n" + " <signal name=\"SetupForUser\">\n" + " <arg name=\"service_name\" type=\"s\"/>\n" + " <arg name=\"x11_display_name\" type=\"s\"/>\n" + " <arg name=\"display_device\" type=\"s\"/>\n" + " <arg name=\"hostname\" type=\"s\"/>\n" + " <arg name=\"username\" type=\"s\"/>\n" + " </signal>\n" + " <signal name=\"Authenticate\">\n" + " </signal>\n" + " <signal name=\"Authorize\">\n" + " </signal>\n" + " <signal name=\"EstablishCredentials\">\n" + " </signal>\n" + " <signal name=\"RenewCredentials\">\n" + " </signal>\n" + " <signal name=\"Open\">\n" " </signal>\n" " <signal name=\"Close\">\n" " </signal>\n" " <signal name=\"StartSession\">\n" " </signal>\n" - " <signal name=\"BeginVerification\">\n" - " <arg name=\"username\" type=\"s\"/>\n" - " </signal>\n" " <signal name=\"AnswerQuery\">\n" " <arg name=\"text\" type=\"s\"/>\n" " </signal>\n" @@ -881,10 +1065,15 @@ gdm_session_relay_constructor (GType type, static void gdm_session_iface_init (GdmSessionIface *iface) { - iface->begin_verification = gdm_session_relay_begin_verification; - iface->begin_verification_for_user = gdm_session_relay_begin_verification_for_user; + iface->open = gdm_session_relay_open; + iface->setup = gdm_session_relay_setup; + iface->setup_for_user = gdm_session_relay_setup_for_user; + iface->authenticate = gdm_session_relay_authenticate; + iface->authorize = gdm_session_relay_authorize; + iface->accredit = gdm_session_relay_accredit; iface->close = gdm_session_relay_close; + iface->cancel = gdm_session_relay_cancel; iface->start_session = gdm_session_relay_start_session; iface->answer_query = gdm_session_relay_answer_query; diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c index 6f7c6699..b6d5754e 100644 --- a/daemon/gdm-session-worker.c +++ b/daemon/gdm-session-worker.c @@ -68,7 +68,7 @@ enum { GDM_SESSION_WORKER_STATE_NONE = 0, - GDM_SESSION_WORKER_STATE_INITIALIZED, + GDM_SESSION_WORKER_STATE_SETUP_COMPLETE, GDM_SESSION_WORKER_STATE_AUTHENTICATED, GDM_SESSION_WORKER_STATE_AUTHORIZED, GDM_SESSION_WORKER_STATE_ACCREDITED, @@ -87,7 +87,7 @@ struct GdmSessionWorkerPrivate GPid child_pid; guint child_watch_id; - /* from BeginAuth */ + /* from Setup */ char *service; char *x11_display_name; char *display_device; @@ -95,12 +95,11 @@ struct GdmSessionWorkerPrivate char *username; gboolean password_is_required; - char **arguments; + int cred_flags; + char **arguments; GHashTable *environment; - guint32 cancelled : 1; - guint state_change_idle_id; char *server_address; @@ -112,21 +111,6 @@ enum { PROP_SERVER_ADDRESS, }; - -enum { - USER_AUTHENTICATED = 0, - USER_AUTHENTICATION_ERROR, - INFO, - PROBLEM, - INFO_QUERY, - SECRET_INFO_QUERY, - SESSION_STARTED, - SESSION_STARTUP_ERROR, - SESSION_EXITED, - SESSION_DIED, - LAST_SIGNAL -}; - static void gdm_session_worker_class_init (GdmSessionWorkerClass *klass); static void gdm_session_worker_init (GdmSessionWorker *session_worker); static void gdm_session_worker_finalize (GObject *object); @@ -258,22 +242,25 @@ gdm_session_execute (const char *file, path = p; p = my_strchrnul (path, ':'); - if (p == path) + if (p == path) { /* Two adjacent colons, or a colon at the beginning or the end * of `PATH' means to search the current directory. */ startp = name + 1; - else + } else { startp = memcpy (name - (p - path), path, p - path); + } /* Try to execute this name. If it works, execv will not return. */ - if (envp) + if (envp) { execve (startp, argv, envp); - else + } else { execv (startp, argv); + } - if (errno == ENOEXEC) + if (errno == ENOEXEC) { script_execute (startp, argv, envp, search_path); + } switch (errno) { case EACCES: @@ -309,11 +296,12 @@ gdm_session_execute (const char *file, } while (*p++ != '\0'); /* We tried every element and none of them worked. */ - if (got_eacces) + if (got_eacces) { /* At least one failure was due to permissions, so report that * error. */ errno = EACCES; + } g_free (freeme); } @@ -458,83 +446,6 @@ send_dbus_void_method (DBusConnection *connection, return TRUE; } -static void -send_authenticated (GdmSessionWorker *worker) -{ - send_dbus_void_method (worker->priv->connection, "Verified"); -} - -static void -send_session_startup_failed (GdmSessionWorker *worker, - const char *msg) -{ - send_dbus_string_method (worker->priv->connection, - "StartupFailed", - msg); -} - -static void -send_session_exited (GdmSessionWorker *worker, - int code) -{ - send_dbus_int_method (worker->priv->connection, - "SessionExited", - code); -} - -static void -send_session_died (GdmSessionWorker *worker, - int num) -{ - send_dbus_int_method (worker->priv->connection, - "SessionDied", - num); -} - -static void -send_username_changed (GdmSessionWorker *worker) -{ - send_dbus_string_method (worker->priv->connection, - "UsernameChanged", - worker->priv->username); -} - -static void -send_authentication_failed (GdmSessionWorker *worker, - const char *msg) -{ - send_dbus_string_method (worker->priv->connection, - "AuthenticationFailed", - msg); -} - -static void -send_authorization_failed (GdmSessionWorker *worker, - const char *msg) -{ - send_dbus_string_method (worker->priv->connection, - "AuthorizationFailed", - msg); -} - -static void -send_accreditation_failed (GdmSessionWorker *worker, - const char *msg) -{ - send_dbus_string_method (worker->priv->connection, - "AccreditationFailed", - msg); -} - -static void -send_session_started (GdmSessionWorker *worker, - GPid pid) -{ - send_dbus_int_method (worker->priv->connection, - "SessionStarted", - (int)pid); -} - static gboolean gdm_session_worker_get_username (GdmSessionWorker *worker, char **username) @@ -575,7 +486,9 @@ gdm_session_worker_update_username (GdmSessionWorker *worker) worker->priv->username = username; username = NULL; - send_username_changed (worker); + send_dbus_string_method (worker->priv->connection, + "UsernameChanged", + worker->priv->username); } out: @@ -959,7 +872,7 @@ gdm_session_worker_initialize_pam (GdmSessionWorker *worker, } g_debug ("GdmSessionWorker: initialized"); - worker->priv->state = GDM_SESSION_WORKER_STATE_INITIALIZED; + worker->priv->state = GDM_SESSION_WORKER_STATE_SETUP_COMPLETE; out: if (error_code != PAM_SUCCESS) { @@ -1198,7 +1111,7 @@ gdm_session_worker_accredit_user (GdmSessionWorker *worker, goto out; } - error_code = pam_setcred (worker->priv->pam_handle, PAM_ESTABLISH_CRED); + error_code = pam_setcred (worker->priv->pam_handle, worker->priv->cred_flags); if (error_code != PAM_SUCCESS) { g_set_error (error, @@ -1296,11 +1209,15 @@ session_worker_child_watch (GPid pid, if (WIFEXITED (status)) { int code = WEXITSTATUS (status); - send_session_exited (worker, code); + send_dbus_int_method (worker->priv->connection, + "SessionExited", + code); } else if (WIFSIGNALED (status)) { int num = WTERMSIG (status); - send_session_died (worker, num); + send_dbus_int_method (worker->priv->connection, + "SessionDied", + num); } gdm_session_worker_uninitialize_pam (worker, PAM_SUCCESS); @@ -1331,6 +1248,8 @@ gdm_session_worker_start_user_session (GdmSessionWorker *worker, g_debug ("GdmSessionWorker: opening user session with program '%s'", worker->priv->arguments[0]); + error_code = PAM_SUCCESS; + session_pid = fork (); if (session_pid < 0) { @@ -1502,7 +1421,7 @@ on_set_environment_variable (GdmSessionWorker *worker, } static void -do_initialize (GdmSessionWorker *worker) +do_setup (GdmSessionWorker *worker) { GError *error; gboolean res; @@ -1516,12 +1435,14 @@ do_initialize (GdmSessionWorker *worker) worker->priv->display_device, &error); if (! res) { - send_authentication_failed (worker, error->message); + send_dbus_string_method (worker->priv->connection, + "SetupFailed", + error->message); g_error_free (error); return; } - queue_state_change (worker); + send_dbus_void_method (worker->priv->connection, "SetupComplete"); } static void @@ -1538,7 +1459,9 @@ do_authenticate (GdmSessionWorker *worker) &error); if (! res) { g_debug ("GdmSessionWorker: Unable to verify user"); - send_authentication_failed (worker, error->message); + send_dbus_string_method (worker->priv->connection, + "AuthenticationFailed", + error->message); g_error_free (error); return; } @@ -1549,8 +1472,7 @@ do_authenticate (GdmSessionWorker *worker) g_debug ("GdmSessionWorker: trying to get updated username"); gdm_session_worker_update_username (worker); - /*send_authenticated (worker);*/ - queue_state_change (worker); + send_dbus_void_method (worker->priv->connection, "Authenticated"); } static void @@ -1566,13 +1488,14 @@ do_authorize (GdmSessionWorker *worker) worker->priv->password_is_required, &error); if (! res) { - send_authorization_failed (worker, error->message); + send_dbus_string_method (worker->priv->connection, + "AuthorizationFailed", + error->message); g_error_free (error); return; } - /*send_authorized (worker);*/ - queue_state_change (worker); + send_dbus_void_method (worker->priv->connection, "Authorized"); } static void @@ -1587,13 +1510,14 @@ do_accredit (GdmSessionWorker *worker) res = gdm_session_worker_accredit_user (worker, &error); if (! res) { - send_accreditation_failed (worker, error->message); + send_dbus_string_method (worker->priv->connection, + "AccreditationFailed", + error->message); g_error_free (error); return; } - /*send_accredited (worker);*/ - send_authenticated (worker); + send_dbus_void_method (worker->priv->connection, "Accredited"); } static void @@ -1605,7 +1529,9 @@ do_open_session (GdmSessionWorker *worker) error = NULL; res = gdm_session_worker_open_user_session (worker, &error); if (! res) { - send_session_startup_failed (worker, error->message); + send_dbus_string_method (worker->priv->connection, + "StartFailed", + error->message); g_error_free (error); return; } @@ -1622,12 +1548,16 @@ do_start_session (GdmSessionWorker *worker) error = NULL; res = gdm_session_worker_start_user_session (worker, &error); if (! res) { - send_session_startup_failed (worker, error->message); + send_dbus_string_method (worker->priv->connection, + "StartFailed", + error->message); g_error_free (error); return; } - send_session_started (worker, worker->priv->child_pid); + send_dbus_int_method (worker->priv->connection, + "SessionStarted", + (int)worker->priv->child_pid); } static gboolean @@ -1641,8 +1571,8 @@ state_change_idle (GdmSessionWorker *worker) worker->priv->state_change_idle_id = 0; switch (new_state) { - case GDM_SESSION_WORKER_STATE_INITIALIZED: - do_initialize (worker); + case GDM_SESSION_WORKER_STATE_SETUP_COMPLETE: + do_setup (worker); break; case GDM_SESSION_WORKER_STATE_AUTHENTICATED: do_authenticate (worker); @@ -1715,8 +1645,8 @@ on_start_program (GdmSessionWorker *worker, } static void -on_begin_verification (GdmSessionWorker *worker, - DBusMessage *message) +on_setup (GdmSessionWorker *worker, + DBusMessage *message) { DBusError error; const char *service; @@ -1742,7 +1672,7 @@ on_begin_verification (GdmSessionWorker *worker, worker->priv->hostname = g_strdup (hostname); worker->priv->username = NULL; - g_debug ("GdmSessionWorker: begin authentication: %s %s", service, console); + g_debug ("GdmSessionWorker: queing setup: %s %s", service, console); queue_state_change (worker); } else { g_warning ("Unable to get arguments: %s", error.message); @@ -1751,8 +1681,8 @@ on_begin_verification (GdmSessionWorker *worker, } static void -on_begin_verification_for_user (GdmSessionWorker *worker, - DBusMessage *message) +on_setup_for_user (GdmSessionWorker *worker, + DBusMessage *message) { DBusError error; const char *service; @@ -1780,7 +1710,7 @@ on_begin_verification_for_user (GdmSessionWorker *worker, worker->priv->hostname = g_strdup (hostname); worker->priv->username = g_strdup (username); - g_debug ("GdmSessionWorker: begin authentication: %s %s", service, console); + g_debug ("GdmSessionWorker: queuing setup for user %s %s", service, console); queue_state_change (worker); } else { g_warning ("Unable to get arguments: %s", error.message); @@ -1788,6 +1718,44 @@ on_begin_verification_for_user (GdmSessionWorker *worker, } } +static void +on_authenticate (GdmSessionWorker *worker, + DBusMessage *message) +{ + /* FIXME: return error if not in SETUP_COMPLETE state */ + queue_state_change (worker); +} + +static void +on_authorize (GdmSessionWorker *worker, + DBusMessage *message) +{ + /* FIXME: return error if not in AUTHENTICATED state */ + queue_state_change (worker); +} + +static void +on_establish_credentials (GdmSessionWorker *worker, + DBusMessage *message) +{ + /* FIXME: return error if not in AUTHORIZED state */ + + worker->priv->cred_flags = PAM_ESTABLISH_CRED; + + queue_state_change (worker); +} + +static void +on_renew_credentials (GdmSessionWorker *worker, + DBusMessage *message) +{ + /* FIXME: return error if not in AUTHORIZED state */ + + worker->priv->cred_flags = PAM_REINITIALIZE_CRED; + + queue_state_change (worker); +} + static DBusHandlerResult worker_dbus_handle_message (DBusConnection *connection, DBusMessage *message, @@ -1807,14 +1775,22 @@ worker_dbus_handle_message (DBusConnection *connection, g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED); g_return_val_if_fail (message != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED); - if (dbus_message_is_signal (message, GDM_SESSION_DBUS_INTERFACE, "StartProgram")) { + if (dbus_message_is_signal (message, GDM_SESSION_DBUS_INTERFACE, "Setup")) { + on_setup (worker, message); + } else if (dbus_message_is_signal (message, GDM_SESSION_DBUS_INTERFACE, "SetupForUser")) { + on_setup_for_user (worker, message); + } else if (dbus_message_is_signal (message, GDM_SESSION_DBUS_INTERFACE, "Authenticate")) { + on_authenticate (worker, message); + } else if (dbus_message_is_signal (message, GDM_SESSION_DBUS_INTERFACE, "Authorize")) { + on_authorize (worker, message); + } else if (dbus_message_is_signal (message, GDM_SESSION_DBUS_INTERFACE, "EstablishCredentials")) { + on_establish_credentials (worker, message); + } else if (dbus_message_is_signal (message, GDM_SESSION_DBUS_INTERFACE, "RenewCredentials")) { + on_renew_credentials (worker, message); + } else if (dbus_message_is_signal (message, GDM_SESSION_DBUS_INTERFACE, "StartProgram")) { on_start_program (worker, message); } else if (dbus_message_is_signal (message, GDM_SESSION_DBUS_INTERFACE, "SetEnvironmentVariable")) { on_set_environment_variable (worker, message); - } else if (dbus_message_is_signal (message, GDM_SESSION_DBUS_INTERFACE, "BeginVerification")) { - on_begin_verification (worker, message); - } else if (dbus_message_is_signal (message, GDM_SESSION_DBUS_INTERFACE, "BeginVerificationForUser")) { - on_begin_verification_for_user (worker, message); } else { return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c index 5d048b2b..99548915 100644 --- a/daemon/gdm-session.c +++ b/daemon/gdm-session.c @@ -28,20 +28,26 @@ #include "gdm-session-private.h" enum { - USER_VERIFIED = 0, - USER_VERIFICATION_ERROR, + OPENED = 0, + SETUP_COMPLETE, + SETUP_FAILED, + RESET_COMPLETE, + RESET_FAILED, + AUTHENTICATED, + AUTHENTICATION_FAILED, + AUTHORIZED, + AUTHORIZATION_FAILED, + ACCREDITED, + ACCREDITATION_FAILED, + CLOSED, INFO, PROBLEM, INFO_QUERY, SECRET_INFO_QUERY, SESSION_STARTED, - SESSION_STARTUP_ERROR, + SESSION_START_FAILED, SESSION_EXITED, SESSION_DIED, - OPENED, - CLOSED, - CONNECTED, - DISCONNECTED, SELECTED_USER_CHANGED, LAST_SIGNAL }; @@ -85,20 +91,45 @@ gdm_session_close (GdmSession *session) } void -gdm_session_begin_verification (GdmSession *session) +gdm_session_setup (GdmSession *session) +{ + g_return_if_fail (GDM_IS_SESSION (session)); + + GDM_SESSION_GET_IFACE (session)->setup (session); +} + +void +gdm_session_setup_for_user (GdmSession *session, + const char *username) { g_return_if_fail (GDM_IS_SESSION (session)); - GDM_SESSION_GET_IFACE (session)->begin_verification (session); + GDM_SESSION_GET_IFACE (session)->setup_for_user (session, username); } void -gdm_session_begin_verification_for_user (GdmSession *session, - const char *username) +gdm_session_authenticate (GdmSession *session) { g_return_if_fail (GDM_IS_SESSION (session)); - GDM_SESSION_GET_IFACE (session)->begin_verification_for_user (session, username); + GDM_SESSION_GET_IFACE (session)->authenticate (session); +} + +void +gdm_session_authorize (GdmSession *session) +{ + g_return_if_fail (GDM_IS_SESSION (session)); + + GDM_SESSION_GET_IFACE (session)->authorize (session); +} + +void +gdm_session_accredit (GdmSession *session, + int flag) +{ + g_return_if_fail (GDM_IS_SESSION (session)); + + GDM_SESSION_GET_IFACE (session)->accredit (session, flag); } void @@ -158,27 +189,122 @@ gdm_session_class_init (gpointer g_iface) { GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); - signals [USER_VERIFIED] = - g_signal_new ("user-verified", + signals [OPENED] = + g_signal_new ("opened", + iface_type, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GdmSessionIface, opened), + NULL, + NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + signals [SETUP_COMPLETE] = + g_signal_new ("setup-complete", + iface_type, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GdmSessionIface, setup_complete), + NULL, + NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + signals [SETUP_FAILED] = + g_signal_new ("setup-failed", iface_type, G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GdmSessionIface, user_verified), + G_STRUCT_OFFSET (GdmSessionIface, setup_failed), + NULL, + NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, + 1, + G_TYPE_STRING); + signals [RESET_COMPLETE] = + g_signal_new ("reset-complete", + iface_type, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GdmSessionIface, reset_complete), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - signals [USER_VERIFICATION_ERROR] = - g_signal_new ("user-verification-error", + signals [RESET_FAILED] = + g_signal_new ("reset-failed", iface_type, G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GdmSessionIface, user_verification_error), + G_STRUCT_OFFSET (GdmSessionIface, reset_failed), NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); + signals [AUTHENTICATED] = + g_signal_new ("authenticated", + iface_type, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GdmSessionIface, authenticated), + NULL, + NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + signals [AUTHENTICATION_FAILED] = + g_signal_new ("authentication-failed", + iface_type, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GdmSessionIface, authentication_failed), + NULL, + NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, + 1, + G_TYPE_STRING); + signals [AUTHORIZED] = + g_signal_new ("authorized", + iface_type, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GdmSessionIface, authorized), + NULL, + NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + signals [AUTHORIZATION_FAILED] = + g_signal_new ("authorization-failed", + iface_type, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GdmSessionIface, authorization_failed), + NULL, + NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, + 1, + G_TYPE_STRING); + signals [ACCREDITED] = + g_signal_new ("accredited", + iface_type, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GdmSessionIface, accredited), + NULL, + NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + signals [ACCREDITATION_FAILED] = + g_signal_new ("accreditation-failed", + iface_type, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GdmSessionIface, accreditation_failed), + NULL, + NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, + 1, + G_TYPE_STRING); + signals [INFO_QUERY] = g_signal_new ("info-query", iface_type, @@ -233,11 +359,11 @@ gdm_session_class_init (gpointer g_iface) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - signals [SESSION_STARTUP_ERROR] = - g_signal_new ("session-startup-error", + signals [SESSION_START_FAILED] = + g_signal_new ("session-start-failed", iface_type, G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GdmSessionIface, session_startup_error), + G_STRUCT_OFFSET (GdmSessionIface, session_start_failed), NULL, NULL, g_cclosure_marshal_VOID__STRING, @@ -266,16 +392,6 @@ gdm_session_class_init (gpointer g_iface) G_TYPE_NONE, 1, G_TYPE_INT); - signals [OPENED] = - g_signal_new ("opened", - iface_type, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GdmSessionIface, opened), - NULL, - NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); signals [CLOSED] = g_signal_new ("closed", iface_type, @@ -301,19 +417,83 @@ gdm_session_class_init (gpointer g_iface) } void -_gdm_session_user_verified (GdmSession *session) +_gdm_session_setup_complete (GdmSession *session) { g_return_if_fail (GDM_IS_SESSION (session)); - g_signal_emit (session, signals [USER_VERIFIED], 0); + g_signal_emit (session, signals [SETUP_COMPLETE], 0); +} + +void +_gdm_session_setup_failed (GdmSession *session, + const char *text) +{ + g_return_if_fail (GDM_IS_SESSION (session)); + g_signal_emit (session, signals [SETUP_FAILED], 0, text); } void -_gdm_session_user_verification_error (GdmSession *session, - const char *text) +_gdm_session_reset_complete (GdmSession *session) { g_return_if_fail (GDM_IS_SESSION (session)); - g_signal_emit (session, signals [USER_VERIFICATION_ERROR], 0, text); + + g_signal_emit (session, signals [RESET_COMPLETE], 0); +} + +void +_gdm_session_reset_failed (GdmSession *session, + const char *text) +{ + g_return_if_fail (GDM_IS_SESSION (session)); + g_signal_emit (session, signals [RESET_FAILED], 0, text); +} + +void +_gdm_session_authenticated (GdmSession *session) +{ + g_return_if_fail (GDM_IS_SESSION (session)); + + g_signal_emit (session, signals [AUTHENTICATED], 0); +} + +void +_gdm_session_authentication_failed (GdmSession *session, + const char *text) +{ + g_return_if_fail (GDM_IS_SESSION (session)); + g_signal_emit (session, signals [AUTHENTICATION_FAILED], 0, text); +} + +void +_gdm_session_authorized (GdmSession *session) +{ + g_return_if_fail (GDM_IS_SESSION (session)); + + g_signal_emit (session, signals [AUTHORIZED], 0); +} + +void +_gdm_session_authorization_failed (GdmSession *session, + const char *text) +{ + g_return_if_fail (GDM_IS_SESSION (session)); + g_signal_emit (session, signals [AUTHORIZATION_FAILED], 0, text); +} + +void +_gdm_session_accredited (GdmSession *session) +{ + g_return_if_fail (GDM_IS_SESSION (session)); + + g_signal_emit (session, signals [ACCREDITED], 0); +} + +void +_gdm_session_accreditation_failed (GdmSession *session, + const char *text) +{ + g_return_if_fail (GDM_IS_SESSION (session)); + g_signal_emit (session, signals [ACCREDITATION_FAILED], 0, text); } void @@ -356,11 +536,11 @@ _gdm_session_session_started (GdmSession *session) } void -_gdm_session_session_startup_error (GdmSession *session, - const char *text) +_gdm_session_session_start_failed (GdmSession *session, + const char *text) { g_return_if_fail (GDM_IS_SESSION (session)); - g_signal_emit (session, signals [SESSION_STARTUP_ERROR], 0, text); + g_signal_emit (session, signals [SESSION_START_FAILED], 0, text); } void diff --git a/daemon/gdm-session.h b/daemon/gdm-session.h index 5a14f54b..50cf28bb 100644 --- a/daemon/gdm-session.h +++ b/daemon/gdm-session.h @@ -35,14 +35,25 @@ G_BEGIN_DECLS typedef struct _GdmSession GdmSession; /* Dummy typedef */ typedef struct _GdmSessionIface GdmSessionIface; +enum { + GDM_SESSION_CRED_ESTABLISH = 0, + GDM_SESSION_CRED_RENEW, +}; + struct _GdmSessionIface { GTypeInterface base_iface; /* Methods */ - void (* begin_verification) (GdmSession *session); - void (* begin_verification_for_user) (GdmSession *session, + void (* open) (GdmSession *session); + void (* setup) (GdmSession *session); + void (* setup_for_user) (GdmSession *session, const char *username); + void (* reset) (GdmSession *session); + void (* authenticate) (GdmSession *session); + void (* authorize) (GdmSession *session); + void (* accredit) (GdmSession *session, + int cred_flag); void (* answer_query) (GdmSession *session, const char *text); void (* select_language) (GdmSession *session, @@ -51,15 +62,27 @@ struct _GdmSessionIface const char *text); void (* select_user) (GdmSession *session, const char *text); - void (* open) (GdmSession *session); + void (* start_session) (GdmSession *session); void (* close) (GdmSession *session); void (* cancel) (GdmSession *session); - void (* start_session) (GdmSession *session); /* Signals */ - void (* user_verified) (GdmSession *session); - void (* user_verification_error) (GdmSession *session, + void (* setup_complete) (GdmSession *session); + void (* setup_failed) (GdmSession *session, + const char *message); + void (* reset_complete) (GdmSession *session); + void (* reset_failed) (GdmSession *session, + const char *message); + void (* authenticated) (GdmSession *session); + void (* authentication_failed) (GdmSession *session, + const char *message); + void (* authorized) (GdmSession *session); + void (* authorization_failed) (GdmSession *session, const char *message); + void (* accredited) (GdmSession *session); + void (* accreditation_failed) (GdmSession *session, + const char *message); + void (* info_query) (GdmSession *session, const char *query_text); void (* secret_info_query) (GdmSession *session, @@ -69,7 +92,7 @@ struct _GdmSessionIface void (* problem) (GdmSession *session, const char *problem); void (* session_started) (GdmSession *session); - void (* session_startup_error) (GdmSession *session, + void (* session_start_failed) (GdmSession *session, const char *message); void (* session_exited) (GdmSession *session, int exit_code); @@ -84,9 +107,18 @@ struct _GdmSessionIface GType gdm_session_get_type (void) G_GNUC_CONST; -void gdm_session_begin_verification (GdmSession *session); -void gdm_session_begin_verification_for_user (GdmSession *session, +void gdm_session_open (GdmSession *session); +void gdm_session_setup (GdmSession *session); +void gdm_session_setup_for_user (GdmSession *session, const char *username); +void gdm_session_reset (GdmSession *session); +void gdm_session_authenticate (GdmSession *session); +void gdm_session_authorize (GdmSession *session); +void gdm_session_accredit (GdmSession *session, + int cred_flag); +void gdm_session_start_session (GdmSession *session); +void gdm_session_close (GdmSession *session); + void gdm_session_answer_query (GdmSession *session, const char *text); void gdm_session_select_session (GdmSession *session, @@ -95,10 +127,7 @@ void gdm_session_select_language (GdmSession *session, const char *language); void gdm_session_select_user (GdmSession *session, const char *username); -void gdm_session_open (GdmSession *session); -void gdm_session_close (GdmSession *session); void gdm_session_cancel (GdmSession *session); -void gdm_session_start_session (GdmSession *session); G_END_DECLS diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c index c905636f..f27ade28 100644 --- a/daemon/gdm-simple-slave.c +++ b/daemon/gdm-simple-slave.c @@ -136,10 +136,99 @@ add_user_authorization (GdmSimpleSlave *slave, return ret; } +static gboolean +greeter_reset_timeout (GdmSimpleSlave *slave) +{ + gdm_greeter_server_reset (slave->priv->greeter_server); + slave->priv->greeter_reset_id = 0; + return FALSE; +} + +static void +queue_greeter_reset (GdmSimpleSlave *slave) +{ + if (slave->priv->greeter_reset_id > 0) { + return; + } + + slave->priv->greeter_reset_id = g_timeout_add_seconds (2, (GSourceFunc)greeter_reset_timeout, slave); +} + +static void +on_session_setup_complete (GdmSession *session, + GdmSimpleSlave *slave) +{ + gdm_session_authenticate (session); +} + +static void +on_session_setup_failed (GdmSession *session, + const char *message, + GdmSimpleSlave *slave) +{ + gdm_greeter_server_problem (slave->priv->greeter_server, _("Unable to initialize login system")); + + queue_greeter_reset (slave); +} + +static void +on_session_reset_complete (GdmSession *session, + GdmSimpleSlave *slave) +{ + g_debug ("GdmSimpleSlave: PAM reset"); +} + +static void +on_session_reset_failed (GdmSession *session, + const char *message, + GdmSimpleSlave *slave) +{ + g_critical ("Unable to reset PAM"); +} + static void -on_session_user_verified (GdmSession *session, +on_session_authenticated (GdmSession *session, GdmSimpleSlave *slave) { + gdm_session_authorize (session); +} + +static void +on_session_authentication_failed (GdmSession *session, + const char *message, + GdmSimpleSlave *slave) +{ + gdm_greeter_server_problem (slave->priv->greeter_server, _("Unable to authenticate user")); + + queue_greeter_reset (slave); +} + +static void +on_session_authorized (GdmSession *session, + GdmSimpleSlave *slave) +{ + int flag; + + /* FIXME: check for migration? */ + flag = GDM_SESSION_CRED_ESTABLISH; + + gdm_session_accredit (session, flag); +} + +static void +on_session_authorization_failed (GdmSession *session, + const char *message, + GdmSimpleSlave *slave) +{ + gdm_greeter_server_problem (slave->priv->greeter_server, _("Unable to authorize user")); + + queue_greeter_reset (slave); +} + +static void +on_session_accredited (GdmSession *session, + GdmSimpleSlave *slave) +{ char *auth_file; gdm_greeter_session_stop (slave->priv->greeter); @@ -157,30 +246,12 @@ on_session_user_verified (GdmSession *session, gdm_session_start_session (session); } -static gboolean -greeter_reset_timeout (GdmSimpleSlave *slave) -{ - gdm_greeter_server_reset (slave->priv->greeter_server); - slave->priv->greeter_reset_id = 0; - return FALSE; -} - -static void -queue_greeter_reset (GdmSimpleSlave *slave) -{ - if (slave->priv->greeter_reset_id > 0) { - return; - } - - slave->priv->greeter_reset_id = g_timeout_add_seconds (2, (GSourceFunc)greeter_reset_timeout, slave); -} - static void -on_session_user_verification_error (GdmSession *session, - const char *message, - GdmSimpleSlave *slave) +on_session_accreditation_failed (GdmSession *session, + const char *message, + GdmSimpleSlave *slave) { - gdm_greeter_server_problem (slave->priv->greeter_server, _("Unable to authenticate user")); + gdm_greeter_server_problem (slave->priv->greeter_server, _("Unable establish credentials")); queue_greeter_reset (slave); } @@ -279,42 +350,62 @@ create_new_session (GdmSimpleSlave *slave) "opened", G_CALLBACK (on_session_opened), slave); -#if 0 g_signal_connect (slave->priv->session, - "closed", - G_CALLBACK (on_session_closed), + "setup-complete", + G_CALLBACK (on_session_setup_complete), + slave); + g_signal_connect (slave->priv->session, + "setup-failed", + G_CALLBACK (on_session_setup_failed), + slave); + g_signal_connect (slave->priv->session, + "reset-complete", + G_CALLBACK (on_session_reset_complete), + slave); + g_signal_connect (slave->priv->session, + "reset-failed", + G_CALLBACK (on_session_reset_failed), + slave); + g_signal_connect (slave->priv->session, + "authenticated", + G_CALLBACK (on_session_authenticated), + slave); + g_signal_connect (slave->priv->session, + "authentication-failed", + G_CALLBACK (on_session_authentication_failed), + slave); + g_signal_connect (slave->priv->session, + "authorized", + G_CALLBACK (on_session_authorized), + slave); + g_signal_connect (slave->priv->session, + "authorization-failed", + G_CALLBACK (on_session_authorization_failed), + slave); + g_signal_connect (slave->priv->session, + "accredited", + G_CALLBACK (on_session_accredited), + slave); + g_signal_connect (slave->priv->session, + "accreditation-failed", + G_CALLBACK (on_session_accreditation_failed), slave); -#endif g_signal_connect (slave->priv->session, "info", G_CALLBACK (on_session_info), slave); - g_signal_connect (slave->priv->session, "problem", G_CALLBACK (on_session_problem), slave); - g_signal_connect (slave->priv->session, "info-query", G_CALLBACK (on_session_info_query), slave); - g_signal_connect (slave->priv->session, "secret-info-query", G_CALLBACK (on_session_secret_info_query), slave); - - g_signal_connect (slave->priv->session, - "user-verified", - G_CALLBACK (on_session_user_verified), - slave); - - g_signal_connect (slave->priv->session, - "user-verification-error", - G_CALLBACK (on_session_user_verification_error), - slave); - g_signal_connect (slave->priv->session, "session-started", G_CALLBACK (on_session_started), @@ -327,7 +418,12 @@ create_new_session (GdmSimpleSlave *slave) "session-died", G_CALLBACK (on_session_died), slave); - +#if 0 + g_signal_connect (slave->priv->session, + "closed", + G_CALLBACK (on_session_closed), + slave); +#endif g_signal_connect (slave->priv->session, "selected-user-changed", G_CALLBACK (on_session_selected_user_changed), @@ -353,7 +449,7 @@ on_greeter_begin_verification (GdmGreeterServer *greeter_server, GdmSimpleSlave *slave) { g_debug ("GdmSimpleSlave: begin verification"); - gdm_session_begin_verification (GDM_SESSION (slave->priv->session)); + gdm_session_setup (GDM_SESSION (slave->priv->session)); } static void @@ -362,8 +458,8 @@ on_greeter_begin_verification_for_user (GdmGreeterServer *greeter_server, GdmSimpleSlave *slave) { g_debug ("GdmSimpleSlave: begin verification"); - gdm_session_begin_verification_for_user (GDM_SESSION (slave->priv->session), - username); + gdm_session_setup_for_user (GDM_SESSION (slave->priv->session), + username); } static void diff --git a/daemon/test-session.c b/daemon/test-session.c index c229a415..e503808c 100644 --- a/daemon/test-session.c +++ b/daemon/test-session.c @@ -36,61 +36,129 @@ static void on_open (GdmSession *session, const char *username) { - g_debug ("Got opened: begin auth for %s", username ? username : "(null)"); + g_debug ("Got opened: calling setup..."); - gdm_session_begin_verification (session); + gdm_session_setup (session); } static void -on_session_started (GdmSession *session) +on_session_setup_complete (GdmSession *session, + gpointer data) { - g_print ("session started"); + g_debug ("Session setup complete"); + gdm_session_authenticate (session); } static void -on_session_exited (GdmSession *session, - int exit_code) +on_session_setup_failed (GdmSession *session, + const char *message, + gpointer data) { - g_print ("session exited with code %d\n", exit_code); - exit (0); + g_print ("Unable to initialize PAM: %s\n", message); + + exit (1); } static void -on_session_died (GdmSession *session, - int signal_number) +on_session_reset_complete (GdmSession *session, + gpointer data) { - g_print ("session died with signal %d, (%s)", - signal_number, - g_strsignal (signal_number)); + g_debug ("Session reset complete"); +} + +static void +on_session_reset_failed (GdmSession *session, + const char *message, + gpointer data) +{ + g_print ("Unable to reset PAM: %s\n", message); + + exit (1); +} + +static void +on_session_authenticated (GdmSession *session, + gpointer data) +{ + g_debug ("Session authenticated"); + gdm_session_authorize (session); +} + +static void +on_session_authentication_failed (GdmSession *session, + const char *message, + gpointer data) +{ + g_print ("Unable to authenticate user: %s\n", message); + + exit (1); +} + +static void +on_session_authorized (GdmSession *session, + gpointer data) +{ + g_debug ("Session authorized"); + gdm_session_accredit (session, GDM_SESSION_CRED_ESTABLISH); +} + +static void +on_session_authorization_failed (GdmSession *session, + const char *message, + gpointer data) +{ + g_print ("Unable to authorize user: %s\n", message); + exit (1); } static void -on_user_verified (GdmSession *session) +on_session_accredited (GdmSession *session, + gpointer data) { char *username; username = gdm_session_direct_get_username (GDM_SESSION_DIRECT (session)); - g_print ("%s%ssuccessfully authenticated\n", + g_print ("%s%ssuccessfully accredited\n", username ? username : "", username ? " " : ""); g_free (username); gdm_session_start_session (session); + } static void -on_user_verification_error (GdmSession *session, - const char *message) +on_session_accreditation_failed (GdmSession *session, + const char *message, + gpointer data) { - char *username; + g_print ("Unable to accredit user: %s\n", message); - username = gdm_session_direct_get_username (GDM_SESSION_DIRECT (session)); + exit (1); +} - g_print ("%s%scould not be successfully authenticated: %s\n", - username ? username : "", username ? " " : "", - message); - g_free (username); +static void +on_session_started (GdmSession *session) +{ + g_print ("session started\n"); +} + +static void +on_session_exited (GdmSession *session, + int exit_code) +{ + g_print ("session exited with code %d\n", exit_code); + exit (0); +} + +static void +on_session_died (GdmSession *session, + int signal_number) +{ + g_print ("session died with signal %d, (%s)\n", + signal_number, + g_strsignal (signal_number)); exit (1); } @@ -191,43 +259,78 @@ main (int argc, gdm_session_open (GDM_SESSION (session)); - g_signal_connect (session, "opened", + g_signal_connect (session, + "opened", G_CALLBACK (on_open), username); + g_signal_connect (session, + "setup-complete", + G_CALLBACK (on_session_setup_complete), + NULL); + g_signal_connect (session, + "setup-failed", + G_CALLBACK (on_session_setup_failed), + NULL); + g_signal_connect (session, + "reset-complete", + G_CALLBACK (on_session_reset_complete), + NULL); + g_signal_connect (session, + "reset-failed", + G_CALLBACK (on_session_reset_failed), + NULL); + g_signal_connect (session, + "authenticated", + G_CALLBACK (on_session_authenticated), + NULL); + g_signal_connect (session, + "authentication-failed", + G_CALLBACK (on_session_authentication_failed), + NULL); + g_signal_connect (session, + "authorized", + G_CALLBACK (on_session_authorized), + NULL); + g_signal_connect (session, + "authorization-failed", + G_CALLBACK (on_session_authorization_failed), + NULL); + g_signal_connect (session, + "accredited", + G_CALLBACK (on_session_accredited), + NULL); + g_signal_connect (session, + "accreditation-failed", + G_CALLBACK (on_session_accreditation_failed), + NULL); - g_signal_connect (session, "info", + g_signal_connect (session, + "info", G_CALLBACK (on_info), NULL); - - g_signal_connect (session, "problem", + g_signal_connect (session, + "problem", G_CALLBACK (on_problem), NULL); - - g_signal_connect (session, "info-query", + g_signal_connect (session, + "info-query", G_CALLBACK (on_info_query), NULL); - - g_signal_connect (session, "secret-info-query", + g_signal_connect (session, + "secret-info-query", G_CALLBACK (on_secret_info_query), NULL); - g_signal_connect (session, "user-verified", - G_CALLBACK (on_user_verified), - NULL); - - g_signal_connect (session, "user-verification-error", - G_CALLBACK (on_user_verification_error), - NULL); - - g_signal_connect (session, "session-started", + g_signal_connect (session, + "session-started", G_CALLBACK (on_session_started), NULL); - - g_signal_connect (session, "session-exited", + g_signal_connect (session, + "session-exited", G_CALLBACK (on_session_exited), NULL); - - g_signal_connect (session, "session-died", + g_signal_connect (session, + "session-died", G_CALLBACK (on_session_died), NULL); |