mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-24 04:20:06 +01:00
core: aggregate ConsoleKit sesson data (bgo #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.
This commit is contained in:
parent
5cd14f05b7
commit
08aabc2bee
1 changed files with 25 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue