389c714
From 9c354795892b8c5fd661a35653991a88fabc76bf Mon Sep 17 00:00:00 2001
389c714
From: Ray Strode <rstrode@redhat.com>
389c714
Date: Mon, 24 Oct 2011 16:39:45 -0400
389c714
Subject: [PATCH 1/2] daemon: Don't emit session-exited when non-authenticated
389c714
 worker fails
389c714
389c714
Sometimes PAM modules are finicky and don't die when you tell them to.
389c714
Instead they fail some seconds later.
389c714
389c714
If a user successfully logs in with one stack and another stack is
389c714
being troublesome, then we'll get notified about it finishing up
389c714
after the user is already logged in.
389c714
389c714
When that happens, we erroneously assume the stack finishing is the
389c714
stack the user's session is running on and then proceed to log the
389c714
user out.
389c714
389c714
This commit makes us be a little more careful about our bookkeeping
389c714
so we can ignore failures from slow PAM modules.
389c714
---
389c714
 daemon/gdm-session-direct.c |   23 ++++++++++++++---------
389c714
 1 files changed, 14 insertions(+), 9 deletions(-)
389c714
389c714
diff --git a/daemon/gdm-session-direct.c b/daemon/gdm-session-direct.c
389c714
index e178985..bb2bff8 100644
389c714
--- a/daemon/gdm-session-direct.c
389c714
+++ b/daemon/gdm-session-direct.c
389c714
@@ -91,10 +91,11 @@ struct _GdmSessionDirectPrivate
389c714
 
389c714
         GHashTable          *conversations;
389c714
 
389c714
+        GdmSessionConversation *session_conversation;
389c714
+
389c714
         GList               *pending_connections;
389c714
 
389c714
         GPid                 session_pid;
389c714
-        guint32              is_running : 1;
389c714
 
389c714
         /* object lifetime scope */
389c714
         char                *id;
389c714
@@ -1073,7 +1074,7 @@ gdm_session_direct_handle_session_started (GdmSessionDirect *session,
389c714
                  pid);
389c714
 
389c714
         session->priv->session_pid = pid;
389c714
-        session->priv->is_running = TRUE;
389c714
+        session->priv->session_conversation = conversation;
389c714
 
389c714
         _gdm_session_session_started (GDM_SESSION (session), conversation->service_name, pid);
389c714
 
389c714
@@ -1129,7 +1130,7 @@ gdm_session_direct_handle_session_exited (GdmSessionDirect *session,
389c714
         g_debug ("GdmSessionDirect: Emitting 'session-exited' signal with exit code '%d'",
389c714
                  code);
389c714
 
389c714
-        session->priv->is_running = FALSE;
389c714
+        session->priv->session_conversation = NULL;
389c714
         _gdm_session_session_exited (GDM_SESSION (session), code);
389c714
 
389c714
         return DBUS_HANDLER_RESULT_HANDLED;
389c714
@@ -1158,7 +1159,7 @@ gdm_session_direct_handle_session_died (GdmSessionDirect *session,
389c714
         g_debug ("GdmSessionDirect: Emitting 'session-died' signal with signal number '%d'",
389c714
                  code);
389c714
 
389c714
-        session->priv->is_running = FALSE;
389c714
+        session->priv->session_conversation = NULL;
389c714
         _gdm_session_session_died (GDM_SESSION (session), code);
389c714
 
389c714
         return DBUS_HANDLER_RESULT_HANDLED;
389c714
@@ -1790,7 +1791,7 @@ worker_exited (GdmSessionWorkerJob *job,
389c714
         g_debug ("GdmSessionDirect: Worker job exited: %d", code);
389c714
 
389c714
         g_object_ref (conversation->job);
389c714
-        if (conversation->session->priv->is_running) {
389c714
+        if (conversation->session->priv->session_conversation == conversation) {
389c714
                 _gdm_session_session_exited (GDM_SESSION (conversation->session), code);
389c714
         }
389c714
 
389c714
@@ -1819,7 +1820,7 @@ worker_died (GdmSessionWorkerJob *job,
389c714
         g_debug ("GdmSessionDirect: Worker job died: %d", signum);
389c714
 
389c714
         g_object_ref (conversation->job);
389c714
-        if (conversation->session->priv->is_running) {
389c714
+        if (conversation->session->priv->session_conversation == conversation) {
389c714
                 _gdm_session_session_died (GDM_SESSION (conversation->session), signum);
389c714
         }
389c714
 
389c714
@@ -2442,6 +2443,10 @@ stop_all_other_conversations (GdmSessionDirect        *session,
389c714
                                              g_strdup (conversation_to_keep->service_name),
389c714
                                              conversation_to_keep);
389c714
                 }
389c714
+
389c714
+                if (session->priv->session_conversation != conversation_to_keep) {
389c714
+                        session->priv->session_conversation = NULL;
389c714
+                }
389c714
         }
389c714
 
389c714
 }
389c714
@@ -2456,7 +2461,7 @@ gdm_session_direct_start_session (GdmSession *session,
389c714
         char             *program;
389c714
 
389c714
         g_return_if_fail (session != NULL);
389c714
-        g_return_if_fail (impl->priv->is_running == FALSE);
389c714
+        g_return_if_fail (impl->priv->session_conversation == NULL);
389c714
 
389c714
         conversation = find_conversation_by_name (impl, service_name);
389c714
 
389c714
@@ -2504,7 +2509,7 @@ gdm_session_direct_close (GdmSession *session)
389c714
 
389c714
         g_debug ("GdmSessionDirect: Closing session");
389c714
 
389c714
-        if (impl->priv->is_running) {
389c714
+        if (impl->priv->session_conversation != NULL) {
389c714
                 gdm_session_record_logout (impl->priv->session_pid,
389c714
                                            impl->priv->selected_user,
389c714
                                            impl->priv->display_hostname,
389c714
@@ -2540,7 +2545,7 @@ gdm_session_direct_close (GdmSession *session)
389c714
         g_hash_table_remove_all (impl->priv->environment);
389c714
 
389c714
         impl->priv->session_pid = -1;
389c714
-        impl->priv->is_running = FALSE;
389c714
+        impl->priv->session_conversation = NULL;
389c714
 }
389c714
 
389c714
 static void
389c714
-- 
389c714
1.7.6.2
389c714
389c714
389c714
From 9c874ee6f595906faf59f891f20492530888804b Mon Sep 17 00:00:00 2001
389c714
From: Ray Strode <rstrode@redhat.com>
389c714
Date: Mon, 24 Oct 2011 16:45:46 -0400
389c714
Subject: [PATCH 2/2] worker: don't block SIGTERM
389c714
389c714
If the slave tells us to go away, we should go away,
389c714
not wait a PAM module decides to let us get back to the
389c714
main loop.
389c714
---
389c714
 daemon/session-worker-main.c |    1 -
389c714
 1 files changed, 0 insertions(+), 1 deletions(-)
389c714
389c714
diff --git a/daemon/session-worker-main.c b/daemon/session-worker-main.c
389c714
index 9d40b8d..42fcd52 100644
389c714
--- a/daemon/session-worker-main.c
389c714
+++ b/daemon/session-worker-main.c
389c714
@@ -188,7 +188,6 @@ main (int    argc,
389c714
         gdm_signal_handler_set_fatal_func (signal_handler,
389c714
                                            (GDestroyNotify)g_main_loop_quit,
389c714
                                            main_loop);
389c714
-        gdm_signal_handler_add (signal_handler, SIGTERM, signal_cb, NULL);
389c714
         gdm_signal_handler_add (signal_handler, SIGINT, signal_cb, NULL);
389c714
         gdm_signal_handler_add (signal_handler, SIGILL, signal_cb, NULL);
389c714
         gdm_signal_handler_add (signal_handler, SIGBUS, signal_cb, NULL);
389c714
-- 
389c714
1.7.6.2
389c714