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

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