"Database already locked", error, NULL);
}
+ FILE *fpasswd = fopen("/etc/passwd", "r");
+
fn = gum_config_get_string (config, GUM_CONFIG_GENERAL_PASSWD_FILE);
- if (!fn || !(fp = fopen (fn, "r"))) {
+ if (!fn || !fpasswd || !(fp = fopen (fn, "r"))) {
gum_lock_pwdf_unlock ();
+ if (fpasswd)
+ fclose (fpasswd);
GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_OPEN,
"Opening passwd file failed", error, NULL);
}
GUM_CONFIG_GENERAL_SYS_UID_MAX, GUM_USER_INVALID_UID);
g_variant_builder_init (&builder, (const GVariantType *)"au");
- while ((pent = fgetpwent (fp)) != NULL) {
- /* If type is an empty string, all users are fetched. User type is
- * first compared with usertype in gecos field. If gecos field for
- * usertype does not exist, then all the users are considered as
- * normal users other than system users which are filtered out based
- * on system min and max uids
- * */
- ut = _get_usertype_from_gecos (pent);
- if (ut == GUM_USERTYPE_NONE) {
- if (pent->pw_uid >=sys_uid_min && pent->pw_uid <= sys_uid_max)
- ut = GUM_USERTYPE_SYSTEM;
- }
- if (ut & in_types) {
- g_variant_builder_add (&builder, "u", pent->pw_uid);
- }
- pent = NULL;
+
+ FILE *fparr[] = {fpasswd, fp};
+ for (int i = 0; i < G_N_ELEMENTS(fparr); i++) {
+ while ((pent = fgetpwent (fparr[i])) != NULL) {
+ /* If type is an empty string, all users are fetched. User type is
+ * first compared with usertype in gecos field. If gecos field for
+ * usertype does not exist, then all the users are considered as
+ * normal users other than system users which are filtered out based
+ * on system min and max uids
+ * */
+ ut = _get_usertype_from_gecos (pent);
+ if (ut == GUM_USERTYPE_NONE) {
+ if (pent->pw_uid >=sys_uid_min && pent->pw_uid <= sys_uid_max)
+ ut = GUM_USERTYPE_SYSTEM;
+ }
+ if (ut & in_types) {
+ g_variant_builder_add (&builder, "u", pent->pw_uid);
+ }
+ pent = NULL;
+ }
}
+
users = g_variant_builder_end (&builder);
fclose (fp);
+ fclose (fpasswd);
gum_lock_pwdf_unlock ();
return users;