Blame SOURCES/0012-lib-don-t-track-user-added-user-removed-until-we-get.patch

34a24a
From f674b04a79a7974a697ad69a997bec21742d3299 Mon Sep 17 00:00:00 2001
34a24a
From: Ray Strode <rstrode@redhat.com>
34a24a
Date: Wed, 4 Oct 2017 11:21:44 -0400
34a24a
Subject: [PATCH 12/13] lib: don't track user-added/user-removed until we get
34a24a
 initial list
34a24a
34a24a
There's no reason to process user-added and user-removed signals
34a24a
until we have our starting list.  Those signals are supposed to
34a24a
be a delta off that list anyway.
34a24a
---
34a24a
 src/libaccountsservice/act-user-manager.c | 14 ++++++++++++++
34a24a
 1 file changed, 14 insertions(+)
34a24a
34a24a
diff --git a/src/libaccountsservice/act-user-manager.c b/src/libaccountsservice/act-user-manager.c
34a24a
index c8a0e20..11049e0 100644
34a24a
--- a/src/libaccountsservice/act-user-manager.c
34a24a
+++ b/src/libaccountsservice/act-user-manager.c
34a24a
@@ -173,60 +173,61 @@ typedef struct
34a24a
         char                       *object_path;
34a24a
         char                       *description;
34a24a
 } ActUserManagerFetchUserRequest;
34a24a
 
34a24a
 struct ActUserManagerPrivate
34a24a
 {
34a24a
         GHashTable            *normal_users_by_name;
34a24a
         GHashTable            *system_users_by_name;
34a24a
         GHashTable            *users_by_object_path;
34a24a
         GHashTable            *sessions;
34a24a
         GDBusConnection       *connection;
34a24a
         AccountsAccounts      *accounts_proxy;
34a24a
         ConsoleKitManager     *ck_manager_proxy;
34a24a
 
34a24a
         ActUserManagerSeat     seat;
34a24a
 
34a24a
         GSList                *new_sessions;
34a24a
         GSList                *new_users;
34a24a
         GSList                *new_users_inhibiting_load;
34a24a
         GSList                *fetch_user_requests;
34a24a
 
34a24a
         GSList                *exclude_usernames;
34a24a
         GSList                *include_usernames;
34a24a
 
34a24a
         guint                  load_id;
34a24a
 
34a24a
         gboolean               is_loaded;
34a24a
         gboolean               has_multiple_users;
34a24a
         gboolean               getting_sessions;
34a24a
         gboolean               listing_cached_users;
34a24a
+        gboolean               list_cached_users_done;
34a24a
 };
34a24a
 
34a24a
 enum {
34a24a
         PROP_0,
34a24a
         PROP_INCLUDE_USERNAMES_LIST,
34a24a
         PROP_EXCLUDE_USERNAMES_LIST,
34a24a
         PROP_IS_LOADED,
34a24a
         PROP_HAS_MULTIPLE_USERS
34a24a
 };
34a24a
 
34a24a
 enum {
34a24a
         USER_ADDED,
34a24a
         USER_REMOVED,
34a24a
         USER_IS_LOGGED_IN_CHANGED,
34a24a
         USER_CHANGED,
34a24a
         LAST_SIGNAL
34a24a
 };
34a24a
 
34a24a
 static guint signals [LAST_SIGNAL] = { 0, };
34a24a
 
34a24a
 static void     act_user_manager_class_init (ActUserManagerClass *klass);
34a24a
 static void     act_user_manager_init       (ActUserManager      *user_manager);
34a24a
 static void     act_user_manager_finalize   (GObject             *object);
34a24a
 
34a24a
 static gboolean ensure_accounts_proxy       (ActUserManager *manager);
34a24a
 static gboolean load_seat_incrementally     (ActUserManager *manager);
34a24a
 static void     unload_seat                 (ActUserManager *manager);
34a24a
 static void     load_users                  (ActUserManager *manager);
34a24a
 static void     act_user_manager_queue_load (ActUserManager *manager);
34a24a
 static void     queue_load_seat_and_users   (ActUserManager *manager);
34a24a
@@ -1075,80 +1076,92 @@ add_new_user_for_object_path (const char     *object_path,
34a24a
         if (user != NULL) {
34a24a
                 g_debug ("ActUserManager: tracking existing %s with object path %s",
34a24a
                          describe_user (user), object_path);
34a24a
                 return user;
34a24a
         }
34a24a
 
34a24a
         user = find_new_user_with_object_path (manager, object_path);
34a24a
 
34a24a
         if (user != NULL) {
34a24a
                 g_debug ("ActUserManager: tracking existing (but very recently added) %s with object path %s",
34a24a
                          describe_user (user), object_path);
34a24a
                 return user;
34a24a
         }
34a24a
 
34a24a
         g_debug ("ActUserManager: tracking new user with object path %s", object_path);
34a24a
 
34a24a
         user = create_new_user (manager);
34a24a
         _act_user_update_from_object_path (user, object_path);
34a24a
 
34a24a
         return user;
34a24a
 }
34a24a
 
34a24a
 static void
34a24a
 on_new_user_in_accounts_service (GDBusProxy *proxy,
34a24a
                                  const char *object_path,
34a24a
                                  gpointer    user_data)
34a24a
 {
34a24a
         ActUserManager *manager = ACT_USER_MANAGER (user_data);
34a24a
         ActUser *user;
34a24a
 
34a24a
+        /* Only track user changes if the user has requested a list
34a24a
+         * of users */
34a24a
+        if (!manager->priv->list_cached_users_done) {
34a24a
+                return;
34a24a
+        }
34a24a
+
34a24a
         if (!manager->priv->is_loaded) {
34a24a
                 g_debug ("ActUserManager: ignoring new user in accounts service with object path %s since not loaded yet", object_path);
34a24a
                 return;
34a24a
         }
34a24a
 
34a24a
         g_debug ("ActUserManager: new user in accounts service with object path %s", object_path);
34a24a
         user = add_new_user_for_object_path (object_path, manager);
34a24a
 
34a24a
         g_object_unref (user);
34a24a
 }
34a24a
 
34a24a
 static void
34a24a
 on_user_removed_in_accounts_service (GDBusProxy *proxy,
34a24a
                                      const char *object_path,
34a24a
                                      gpointer    user_data)
34a24a
 {
34a24a
         ActUserManager *manager = ACT_USER_MANAGER (user_data);
34a24a
         ActUser        *user;
34a24a
         GSList         *node;
34a24a
 
34a24a
+        /* Only track user changes if the user has requested a list
34a24a
+         * of users */
34a24a
+        if (!manager->priv->list_cached_users_done) {
34a24a
+                return;
34a24a
+        }
34a24a
+
34a24a
         user = g_hash_table_lookup (manager->priv->users_by_object_path, object_path);
34a24a
 
34a24a
         if (user == NULL) {
34a24a
                 g_debug ("ActUserManager: ignoring untracked user %s", object_path);
34a24a
                 return;
34a24a
         } else {
34a24a
                 g_debug ("ActUserManager: tracked user %s removed from accounts service", object_path);
34a24a
         }
34a24a
 
34a24a
         node = g_slist_find (manager->priv->new_users, user);
34a24a
         if (node != NULL) {
34a24a
                 g_signal_handlers_disconnect_by_func (user, on_new_user_loaded, manager);
34a24a
                 g_object_unref (user);
34a24a
                 manager->priv->new_users = g_slist_delete_link (manager->priv->new_users, node);
34a24a
         }
34a24a
 
34a24a
         remove_user (manager, user);
34a24a
 }
34a24a
 
34a24a
 static void
34a24a
 on_get_current_session_finished (GObject        *object,
34a24a
                                  GAsyncResult   *result,
34a24a
                                  gpointer        data)
34a24a
 {
34a24a
         ConsoleKitManager *proxy = CONSOLE_KIT_MANAGER (object);
34a24a
         ActUserManager    *manager = data;
34a24a
         GError            *error = NULL;
34a24a
         char              *session_id;
34a24a
 
34a24a
         g_assert (manager->priv->seat.state == ACT_USER_MANAGER_SEAT_STATE_GET_SESSION_ID);
34a24a
@@ -1532,60 +1545,61 @@ load_included_usernames (ActUserManager *manager)
34a24a
 {
34a24a
         GSList *l;
34a24a
 
34a24a
         /* Add users who are specifically included */
34a24a
         for (l = manager->priv->include_usernames; l != NULL; l = l->next) {
34a24a
                 ActUser *user;
34a24a
 
34a24a
                 g_debug ("ActUserManager: Adding included user %s", (char *)l->data);
34a24a
                 /*
34a24a
                  * The call to act_user_manager_get_user will add the user if it is
34a24a
                  * valid and not already in the hash.
34a24a
                  */
34a24a
                 user = act_user_manager_get_user (manager, l->data);
34a24a
                 if (user == NULL) {
34a24a
                         g_debug ("ActUserManager: unable to lookup user '%s'", (char *)l->data);
34a24a
                 }
34a24a
         }
34a24a
 }
34a24a
 
34a24a
 static void
34a24a
 on_list_cached_users_finished (GObject      *object,
34a24a
                                GAsyncResult *result,
34a24a
                                gpointer      data)
34a24a
 {
34a24a
         AccountsAccounts *proxy = ACCOUNTS_ACCOUNTS (object);
34a24a
         ActUserManager   *manager = data;
34a24a
         gchar           **user_paths;
34a24a
         GError           *error = NULL;
34a24a
 
34a24a
         manager->priv->listing_cached_users = FALSE;
34a24a
+        manager->priv->list_cached_users_done = TRUE;
34a24a
 
34a24a
         if (!accounts_accounts_call_list_cached_users_finish (proxy, &user_paths, result, &error)) {
34a24a
                 g_debug ("ActUserManager: ListCachedUsers failed: %s", error->message);
34a24a
                 g_error_free (error);
34a24a
 
34a24a
                 g_object_unref (manager->priv->accounts_proxy);
34a24a
                 manager->priv->accounts_proxy = NULL;
34a24a
 
34a24a
                 g_debug ("ActUserManager: unrefing manager owned by failed ListCachedUsers call");
34a24a
                 g_object_unref (manager);
34a24a
                 return;
34a24a
         }
34a24a
 
34a24a
         load_user_paths (manager, (const char * const *) user_paths);
34a24a
         g_strfreev (user_paths);
34a24a
 
34a24a
         load_included_usernames (manager);
34a24a
 
34a24a
         g_debug ("ActUserManager: unrefing manager owned by finished ListCachedUsers call");
34a24a
         g_object_unref (manager);
34a24a
 }
34a24a
 
34a24a
 static void
34a24a
 on_get_x11_display_finished (GObject      *object,
34a24a
                              GAsyncResult *result,
34a24a
                              gpointer      data)
34a24a
 {
34a24a
         ConsoleKitSession *proxy = CONSOLE_KIT_SESSION (object);
34a24a
         ActUserManagerNewSession *new_session = data;
34a24a
         GError            *error = NULL;
34a24a
-- 
34a24a
2.14.1
34a24a