diff options
author | Dan Williams <dcbw@redhat.com> | 2011-04-11 16:35:38 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2011-04-11 16:35:38 -0500 |
commit | 328068c7fe405b6601d46fc011ed67e6de84e3d0 (patch) | |
tree | 90335523ca82c0e8c6e59ceb891d8b7075d17635 /src/nm-session-monitor.c | |
parent | c7d1bf18c45cb72c2b0cae42f763f98a7d04e4e9 (diff) | |
download | NetworkManager-328068c7fe405b6601d46fc011ed67e6de84e3d0.tar.gz |
core: aggregate ConsoleKit sesson data (rh #647454)
Jan Schmidt noticed that things didn't work as expected with
multiple sessions of the same user, since when inserting the
new session the old one was forgotten. Thus bad things happened
if you were local in the old session but not in the new one
since only the new one would be considered.
Instead, make the actual data stored the aggregate of all
sessions for that user.
Diffstat (limited to 'src/nm-session-monitor.c')
-rw-r--r-- | src/nm-session-monitor.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/nm-session-monitor.c b/src/nm-session-monitor.c index 4877b77032..c701bdb3b0 100644 --- a/src/nm-session-monitor.c +++ b/src/nm-session-monitor.c @@ -189,6 +189,19 @@ error: return NULL; } +static void +session_merge (Session *src, Session *dest) +{ + g_return_if_fail (src != NULL); + g_return_if_fail (dest != NULL); + + g_warn_if_fail (g_strcmp0 (src->user, dest->user) == 0); + g_warn_if_fail (src->uid == dest->uid); + + dest->local = (dest->local || src->local); + dest->active = (dest->active || src->active); +} + /********************************************************************/ static void @@ -237,14 +250,24 @@ reload_database (NMSessionMonitor *self, GError **error) } for (i = 0; i < len; i++) { + Session *found; + if (!g_str_has_prefix (groups[i], "Session ")) continue; s = session_new (self->database, groups[i], error); if (!s) goto error; - g_hash_table_insert (self->sessions_by_user, (gpointer) s->user, s); - g_hash_table_insert (self->sessions_by_uid, GUINT_TO_POINTER (s->uid), s); + + found = g_hash_table_lookup (self->sessions_by_user, (gpointer) s->user); + if (found) { + session_merge (s, found); + session_free (s); + } else { + /* Entirely new user */ + g_hash_table_insert (self->sessions_by_user, (gpointer) s->user, s); + g_hash_table_insert (self->sessions_by_uid, GUINT_TO_POINTER (s->uid), s); + } } g_strfreev (groups); |