diff options
author | Matthias Clasen <mclasen@redhat.com> | 2012-07-08 00:33:24 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2012-07-09 12:43:07 -0400 |
commit | 93090b7c7f2ae4c945173f4e61357ff801cde768 (patch) | |
tree | 45ea863342f8ee6a308284d842088cfcbf4de1bf | |
parent | 931e38e25a94f4eb8e88141ef6a8f0fb70ced0d8 (diff) | |
download | gdm-93090b7c7f2ae4c945173f4e61357ff801cde768.tar.gz |
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.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | daemon/gdm-slave.c | 19 |
2 files changed, 19 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac index b747e7ae..b70f5372 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 53633c0d..8634ee8a 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) { |