From 5091c27ea63d36e921ef872d0b10995cd287820d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 21 Sep 2012 23:25:44 -0400 Subject: [PATCH] Ignore closing sessions The function act_user_is_logged_in() determines the logged-in-ness of a user by looking at all the session for that user. Recently, systemd introduced a session state 'closing' for session which are 'nominally logged out, but not quite gone yet'. These sessions should be ignored for the purpose of determining logged-in-ness. If we don't, then logging out of a GNOME session shows the user as still logged in on the login screen, and refuses to let him choose another session. --- src/libaccountsservice/act-user-manager.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/libaccountsservice/act-user-manager.c b/src/libaccountsservice/act-user-manager.c index 1e2bf8a..43667b3 100644 --- a/src/libaccountsservice/act-user-manager.c +++ b/src/libaccountsservice/act-user-manager.c @@ -1633,6 +1633,8 @@ reload_systemd_sessions (ActUserManager *manager) int i; char **sessions; GHashTable *systemd_sessions; + char *state; + gboolean is_closing; res = sd_get_sessions (&sessions); @@ -1647,6 +1649,20 @@ reload_systemd_sessions (ActUserManager *manager) if (sessions != NULL) { for (i = 0; sessions[i] != NULL; i ++) { + res = sd_session_get_state (sessions[i], &state); + + if (res < 0) { + g_debug ("Failed to determine state of session %s: %s", sessions[i], strerror (-res)); + continue; + } + + is_closing = g_strcmp0 (state, "closing") == 0; + free (state); + + if (is_closing) { + continue; + } + g_hash_table_insert (systemd_sessions, sessions[i], NULL); } -- 1.7.12