From ee7da640fde5f94d29d8bf0b8372c44be5379ade Mon Sep 17 00:00:00 2001 From: Caleb Callaway Date: Tue, 20 Dec 2011 21:16:45 -0800 Subject: [PATCH] Use getpwent() instead of fgetpwent() to obtain pw entries. --- configure.ac | 1 - src/daemon.c | 25 ++----------------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/configure.ac b/configure.ac index 7c451b0..6004afd 100644 --- a/configure.ac +++ b/configure.ac @@ -121,7 +121,6 @@ WARN_CFLAGS="$accountsservice_cv_warn_cflags" AC_SUBST(WARN_CFLAGS) AC_CHECK_HEADERS([shadow.h utmpx.h]) -AC_CHECK_FUNCS([fgetpwent]) dnl --------------------------------------------------------------------------- dnl - DocBook Documentation diff --git a/src/daemon.c b/src/daemon.c index 35267f6..8ab50ca 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -335,32 +335,18 @@ reload_passwd (Daemon *daemon) GSList *old_users; GSList *new_users; GSList *list; -#ifdef HAVE_FGETPWENT - FILE *fp; -#endif User *user = NULL; old_users = NULL; new_users = NULL; -#ifdef HAVE_FGETPWENT - errno = 0; - fp = fopen (PATH_PASSWD, "r"); - if (fp == NULL) { - g_warning ("Unable to open %s: %s", PATH_PASSWD, g_strerror (errno)); - goto out; - } -#else setpwent(); -#endif + g_hash_table_foreach (daemon->priv->users, listify_hash_values_hfunc, &old_users); g_slist_foreach (old_users, (GFunc) g_object_ref, NULL); -#ifdef HAVE_FGETPWENT - while ((pwent = fgetpwent (fp)) != NULL) { -#else while ((pwent = getpwent ()) != NULL) { -#endif + /* Skip users below MINIMAL_UID... */ if (daemon_local_user_is_excluded (daemon, pwent->pw_name, pwent->pw_uid)) { g_debug ("skipping user: %s", pwent->pw_name); @@ -410,13 +396,6 @@ reload_passwd (Daemon *daemon) } } -#ifdef HAVE_FGETPWENT - out: - /* Cleanup */ - - fclose (fp); -#endif - g_slist_foreach (new_users, (GFunc) g_object_thaw_notify, NULL); g_slist_foreach (new_users, (GFunc) g_object_unref, NULL); g_slist_free (new_users); -- 1.7.5.4