Ray Strode cc3cb7
From 2d9e0f43c46e1be8afd94944e7461e0086497fd3 Mon Sep 17 00:00:00 2001
Ray Strode cc3cb7
From: Ray Strode <rstrode@redhat.com>
Ray Strode cc3cb7
Date: Fri, 4 May 2018 16:43:03 -0400
Ray Strode cc3cb7
Subject: [PATCH 1/2] daemon: unregister user after we're done with it not
Ray Strode cc3cb7
 before
Ray Strode cc3cb7
Ray Strode cc3cb7
Now that we get the object path for a user directly from the skeleton,
Ray Strode cc3cb7
we can't access that object path after the skeleton is unregistered.
Ray Strode cc3cb7
Ray Strode cc3cb7
This commit fixes a problem where the user deletion handling code tries
Ray Strode cc3cb7
to access the object path of a user after its skeleton is unregistered.
Ray Strode cc3cb7
---
Ray Strode cc3cb7
 src/daemon.c | 2 +-
Ray Strode cc3cb7
 1 file changed, 1 insertion(+), 1 deletion(-)
Ray Strode cc3cb7
Ray Strode cc3cb7
diff --git a/src/daemon.c b/src/daemon.c
Ray Strode cc3cb7
index 9ec153a..d3fa971 100644
Ray Strode cc3cb7
--- a/src/daemon.c
Ray Strode cc3cb7
+++ b/src/daemon.c
Ray Strode cc3cb7
@@ -483,63 +483,63 @@ reload_users (Daemon *daemon)
Ray Strode cc3cb7
                 if (!user_get_system_account (user))
Ray Strode cc3cb7
                         number_of_normal_users++;
Ray Strode cc3cb7
                 user_update_local_account_property (user, g_hash_table_lookup (local, name) != NULL);
Ray Strode cc3cb7
         }
Ray Strode cc3cb7
         g_hash_table_destroy (local);
Ray Strode cc3cb7
 
Ray Strode cc3cb7
         had_no_users = accounts_accounts_get_has_no_users (accounts);
Ray Strode cc3cb7
         has_no_users = number_of_normal_users == 0;
Ray Strode cc3cb7
 
Ray Strode cc3cb7
         if (had_no_users != has_no_users)
Ray Strode cc3cb7
                 accounts_accounts_set_has_no_users (accounts, has_no_users);
Ray Strode cc3cb7
 
Ray Strode cc3cb7
         had_multiple_users = accounts_accounts_get_has_multiple_users (accounts);
Ray Strode cc3cb7
         has_multiple_users = number_of_normal_users > 1;
Ray Strode cc3cb7
 
Ray Strode cc3cb7
         if (had_multiple_users != has_multiple_users)
Ray Strode cc3cb7
                 accounts_accounts_set_has_multiple_users (accounts, has_multiple_users);
Ray Strode cc3cb7
 
Ray Strode cc3cb7
         /* Swap out the users */
Ray Strode cc3cb7
         old_users = daemon->priv->users;
Ray Strode cc3cb7
         daemon->priv->users = users;
Ray Strode cc3cb7
 
Ray Strode cc3cb7
         /* Remove all the old users */
Ray Strode cc3cb7
         g_hash_table_iter_init (&iter, old_users);
Ray Strode cc3cb7
         while (g_hash_table_iter_next (&iter, &name, (gpointer *)&user)) {
Ray Strode cc3cb7
                 User *refreshed_user;
Ray Strode cc3cb7
 
Ray Strode cc3cb7
                 refreshed_user = g_hash_table_lookup (users, name);
Ray Strode cc3cb7
 
Ray Strode cc3cb7
                 if (!refreshed_user || !user_get_cached (refreshed_user)) {
Ray Strode cc3cb7
-                        user_unregister (user);
Ray Strode cc3cb7
                         accounts_accounts_emit_user_deleted (ACCOUNTS_ACCOUNTS (daemon),
Ray Strode cc3cb7
                                                              user_get_object_path (user));
Ray Strode cc3cb7
+                        user_unregister (user);
Ray Strode cc3cb7
                 }
Ray Strode cc3cb7
         }
Ray Strode cc3cb7
 
Ray Strode cc3cb7
         /* Register all the new users */
Ray Strode cc3cb7
         g_hash_table_iter_init (&iter, users);
Ray Strode cc3cb7
         while (g_hash_table_iter_next (&iter, &name, (gpointer *)&user)) {
Ray Strode cc3cb7
                 User *stale_user;
Ray Strode cc3cb7
 
Ray Strode cc3cb7
                 stale_user = g_hash_table_lookup (old_users, name);
Ray Strode cc3cb7
 
Ray Strode cc3cb7
                 if (!stale_user || !user_get_cached (stale_user) && user_get_cached (user)) {
Ray Strode cc3cb7
                         user_register (user);
Ray Strode cc3cb7
                         accounts_accounts_emit_user_added (ACCOUNTS_ACCOUNTS (daemon),
Ray Strode cc3cb7
                                                            user_get_object_path (user));
Ray Strode cc3cb7
                 }
Ray Strode cc3cb7
                 g_object_thaw_notify (G_OBJECT (user));
Ray Strode cc3cb7
         }
Ray Strode cc3cb7
 
Ray Strode cc3cb7
         g_hash_table_destroy (old_users);
Ray Strode cc3cb7
 }
Ray Strode cc3cb7
 
Ray Strode cc3cb7
 static gboolean
Ray Strode cc3cb7
 reload_users_timeout (Daemon *daemon)
Ray Strode cc3cb7
 {
Ray Strode cc3cb7
         reload_users (daemon);
Ray Strode cc3cb7
         daemon->priv->reload_id = 0;
Ray Strode cc3cb7
 
Ray Strode cc3cb7
         return FALSE;
Ray Strode cc3cb7
 }
Ray Strode cc3cb7
 
Ray Strode cc3cb7
-- 
Ray Strode cc3cb7
2.17.0
Ray Strode cc3cb7