[gdm/multi-stack: 25/35] When one PAM conversation wins, stop the others
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm/multi-stack: 25/35] When one PAM conversation wins, stop the others
- Date: Fri, 4 Feb 2011 20:14:10 +0000 (UTC)
commit 07882809ff1b9dc0df7d2cf95b5f290894527135
Author: Ray Strode <rstrode redhat com>
Date: Tue Apr 21 10:25:18 2009 -0400
When one PAM conversation wins, stop the others
At some point we'll want to have policy here, to allow
e.g. two factor authentication.
daemon/gdm-session-direct.c | 71 +++++++++++++++++++++++++++++++-----------
daemon/gdm-simple-slave.c | 2 +-
2 files changed, 53 insertions(+), 20 deletions(-)
---
diff --git a/daemon/gdm-session-direct.c b/daemon/gdm-session-direct.c
index 9268bc5..0f0c053 100644
--- a/daemon/gdm-session-direct.c
+++ b/daemon/gdm-session-direct.c
@@ -2268,6 +2268,47 @@ gdm_session_direct_open_session (GdmSession *session,
}
static void
+stop_all_other_conversations (GdmSessionDirect *session,
+ GdmSessionConversation *conversation_to_keep)
+{
+ GHashTableIter iter;
+ gpointer key, value;
+
+ if (session->priv->conversations == NULL) {
+ return;
+ }
+
+ if (conversation_to_keep == NULL) {
+ g_debug ("GdmSessionDirect: Stopping all conversations");
+ } else {
+ g_debug ("GdmSessionDirect: Stopping all conversations "
+ "except for %s", conversation_to_keep->service_name);
+ }
+
+ g_hash_table_iter_init (&iter, session->priv->conversations);
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ GdmSessionConversation *conversation;
+
+ conversation = (GdmSessionConversation *) value;
+
+ if (conversation == conversation_to_keep) {
+ g_hash_table_iter_steal (&iter);
+ g_free (key);
+ } else {
+ stop_conversation (conversation);
+ }
+ }
+
+ g_hash_table_remove_all (session->priv->conversations);
+
+ if (conversation_to_keep != NULL) {
+ g_hash_table_insert (session->priv->conversations,
+ g_strdup (conversation_to_keep->service_name),
+ conversation_to_keep);
+ }
+}
+
+static void
gdm_session_direct_start_session (GdmSession *session,
const char *service_name)
{
@@ -2279,6 +2320,16 @@ gdm_session_direct_start_session (GdmSession *session,
g_return_if_fail (session != NULL);
g_return_if_fail (impl->priv->is_running == FALSE);
+ conversation = find_conversation_by_name (impl, service_name);
+
+ if (conversation == NULL) {
+ g_warning ("GdmSessionDirect: Tried to start session of "
+ "nonexistent conversation %s", service_name);
+ return;
+ }
+
+ stop_all_other_conversations (impl, conversation);
+
command = get_session_command (impl);
if (gdm_session_direct_bypasses_xsession (impl)) {
@@ -2289,8 +2340,6 @@ gdm_session_direct_start_session (GdmSession *session,
g_free (command);
- conversation = find_conversation_by_name (impl, service_name);
-
setup_session_environment (impl);
send_environment (impl, conversation);
@@ -2301,23 +2350,7 @@ gdm_session_direct_start_session (GdmSession *session,
static void
stop_all_conversations (GdmSessionDirect *session)
{
- GHashTableIter iter;
- gpointer key, value;
-
- if (session->priv->conversations == NULL) {
- return;
- }
-
- g_hash_table_iter_init (&iter, session->priv->conversations);
- while (g_hash_table_iter_next (&iter, &key, &value)) {
- GdmSessionConversation *conversation;
-
- conversation = (GdmSessionConversation *) value;
-
- stop_conversation (conversation);
- }
-
- g_hash_table_remove_all (session->priv->conversations);
+ stop_all_other_conversations (session, NULL);
}
static void
diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c
index b77f0c7..ce7a28a 100644
--- a/daemon/gdm-simple-slave.c
+++ b/daemon/gdm-simple-slave.c
@@ -669,7 +669,7 @@ on_session_conversation_stopped (GdmSession *session,
gboolean res;
g_debug ("GdmSimpleSlave: conversation stopped");
- if (slave->priv->greeter_server != NULL) {
+ if (slave->priv->greeter != NULL) {
res = gdm_greeter_server_conversation_stopped (slave->priv->greeter_server,
service_name);
if (! res) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]