[gdm] Ignore lingering sessions



commit 93090b7c7f2ae4c945173f4e61357ff801cde768
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jul 8 00:33:24 2012 -0400

    Ignore lingering sessions
    
    When a session process is slow to die at the session end, or when
    a process is intentionally leaked (such as screen), a session can
    linger for a while after the user logged out.
    Avoid such 'zombie' sessions when looking for an existing session
    to switch to.

 configure.ac       |    2 +-
 daemon/gdm-slave.c |   19 ++++++++++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b747e7a..b70f537 100644
--- a/configure.ac
+++ b/configure.ac
@@ -928,7 +928,7 @@ dnl - Check for systemd support
 dnl ---------------------------------------------------------------------------
 
 PKG_CHECK_MODULES(SYSTEMD,
-                  [libsystemd-login libsystemd-daemon],
+                  [libsystemd-login >= 186 libsystemd-daemon],
                   [have_systemd=yes], [have_systemd=no])
 
 if test "x$with_systemd" = "xauto" ; then
diff --git a/daemon/gdm-slave.c b/daemon/gdm-slave.c
index 53633c0..8634ee8 100644
--- a/daemon/gdm-slave.c
+++ b/daemon/gdm-slave.c
@@ -1417,6 +1417,8 @@ gdm_slave_get_primary_session_id_for_user_from_systemd (GdmSlave   *slave,
 
         for (i = 0; sessions[i] != NULL; i++) {
                 char *type;
+                char *state;
+                gboolean is_closing;
                 gboolean is_active;
                 gboolean is_x11;
                 uid_t other;
@@ -1441,7 +1443,22 @@ gdm_slave_get_primary_session_id_for_user_from_systemd (GdmSlave   *slave,
                 /* Always give preference to non-active sessions,
                  * so we migrate when we can and don't when we can't
                  */
-                is_active = sd_session_is_active (sessions[i]) > 0;
+                res = sd_session_get_state (sessions[i], &state);
+                if (res < 0) {
+                        g_warning ("GdmSlave: could not fetch state of session '%s': %s",
+                                   sessions[i], strerror (-res));
+                        continue;
+                }
+
+                is_closing = g_strcmp0 (state, "closing") == 0;
+                is_active = g_strcmp0 (state, "active") == 0;
+                free (state);
+
+                /* Ignore closing sessions
+                 */
+                if (is_closing) {
+                        continue;
+                }
 
                 res = sd_session_get_uid (sessions[i], &other);
                 if (res == 0 && other == uid && !got_primary_ssid) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]