aboutsummaryrefslogtreecommitdiff
path: root/grp/initgroups.c
diff options
context:
space:
mode:
Diffstat (limited to 'grp/initgroups.c')
-rw-r--r--grp/initgroups.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/grp/initgroups.c b/grp/initgroups.c
index 0c17141117..a60ca1c395 100644
--- a/grp/initgroups.c
+++ b/grp/initgroups.c
@@ -63,7 +63,6 @@ internal_getgrouplist (const char *user, gid_t group, long int *size,
#endif
enum nss_status status = NSS_STATUS_UNAVAIL;
- int no_more = 0;
/* Never store more than the starting *SIZE number of elements. */
assert (*size > 0);
@@ -71,28 +70,23 @@ internal_getgrouplist (const char *user, gid_t group, long int *size,
/* Start is one, because we have the first group as parameter. */
long int start = 1;
- if (__nss_initgroups_database == NULL)
- {
- if (__nss_database_lookup2 ("initgroups", NULL, "",
- &__nss_initgroups_database) < 0)
- {
- if (__nss_group_database == NULL)
- no_more = __nss_database_lookup2 ("group", NULL, "files",
- &__nss_group_database);
+ nss_action_list nip;
- __nss_initgroups_database = __nss_group_database;
- }
- else
- use_initgroups_entry = true;
+ if (__nss_database_get (nss_database_initgroups, &nip))
+ {
+ use_initgroups_entry = true;
+ }
+ else if (__nss_database_get (nss_database_group, &nip))
+ {
+ use_initgroups_entry = false;
}
else
- /* __nss_initgroups_database might have been set through
- __nss_configure_lookup in which case use_initgroups_entry was
- not set here. */
- use_initgroups_entry = __nss_initgroups_database != __nss_group_database;
+ {
+ nip = __nss_action_parse ("files");
+ use_initgroups_entry = false;
+ }
- service_user *nip = __nss_initgroups_database;
- while (! no_more)
+ while (nip && nip->module)
{
long int prev_start = start;
@@ -134,10 +128,7 @@ internal_getgrouplist (const char *user, gid_t group, long int *size,
&& nss_next_action (nip, status) == NSS_ACTION_RETURN)
break;
- if (nip->next == NULL)
- no_more = -1;
- else
- nip = nip->next;
+ nip++;
}
return start;