summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2023-02-17 23:59:12 +0000
committerRay Strode <halfline@gmail.com>2023-02-18 02:44:09 +0000
commit322165ea2e1c1c4715d532910ccb31b3d1e0a04e (patch)
tree36325e4ec2eadaed032f35ac9c6cfcf12411759a
parentc142812f7653cd1f6e52224da8410cd09f102a4f (diff)
downloadaccountsservice-322165ea2e1c1c4715d532910ccb31b3d1e0a04e.tar.gz
daemon: Don't crash if /etc/shadow doesn't exist
Turning off shadow passwords with `shadowconfig off` or `pwunconv` (so that the hashed password is in /etc/passwd) is something that distributions still at least half-support, and apparently some people genuinely do this. After resolving #107 this would cause accountsservice to crash. Looking at the implementation, it seems the same crash would happen if /etc/shadow is present but empty. In this situation, treat all users as non-local (unless cached) with a warning, but don't crash. Bug-Debian: https://bugs.debian.org/1031309 Signed-off-by: Simon McVittie <smcv@debian.org>
-rw-r--r--src/daemon.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/daemon.c b/src/daemon.c
index 0fbd1d7..f6e19ac 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -503,7 +503,6 @@ reload_users (Daemon *daemon)
/* Load the local users into our hash tables */
load_entries (daemon, users, FALSE, entry_generator_fgetpwent, &local);
- g_assert (local != NULL);
/* Now add/update users from other sources, possibly non-local */
load_entries (daemon, users, TRUE, entry_generator_cachedir, NULL);
@@ -519,9 +518,9 @@ reload_users (Daemon *daemon)
User *user = value;
if (!user_get_system_account (user))
number_of_normal_users++;
- user_update_local_account_property (user, g_hash_table_lookup (local, name) != NULL);
+ user_update_local_account_property (user, local != NULL && g_hash_table_lookup (local, name) != NULL);
}
- g_hash_table_destroy (local);
+ g_clear_pointer (&local, g_hash_table_destroy);
had_no_users = accounts_accounts_get_has_no_users (accounts);
has_no_users = number_of_normal_users == 0;