about summary refs log tree commit diff
path: root/grp
diff options
context:
space:
mode:
Diffstat (limited to 'grp')
-rw-r--r--grp/compat-initgroups.c2
-rw-r--r--grp/initgroups.c37
2 files changed, 15 insertions, 24 deletions
diff --git a/grp/compat-initgroups.c b/grp/compat-initgroups.c
index 3dd50d2306..9df940767b 100644
--- a/grp/compat-initgroups.c
+++ b/grp/compat-initgroups.c
@@ -10,7 +10,7 @@ typedef enum nss_status (*get_function) (struct group *, char *,
 
 
 static enum nss_status
-compat_call (service_user *nip, const char *user, gid_t group, long int *start,
+compat_call (nss_action_list nip, const char *user, gid_t group, long int *start,
 	     long int *size, gid_t **groupsp, long int limit, int *errnop)
 {
   struct group grpbuf;
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;