diff mbox series

v5 [PATCH 6/6] nsswitch: use new internal API (callers)

Message ID xnblfa4ois.fsf@greed.delorie.com
State New
Headers show
Series v5 [PATCH 6/6] nsswitch: use new internal API (callers) | expand

Commit Message

DJ Delorie Dec. 3, 2020, 8:34 p.m. UTC
Stitch new ABI and types throughout all NSS callers.
---
 grp/compat-initgroups.c            |  2 +-
 grp/initgroups.c                   | 37 ++++++++--------------
 inet/ether_hton.c                  | 21 ++----------
 inet/ether_ntoh.c                  | 21 ++----------
 inet/getnetgrent_r.c               | 40 ++++-------------------
 inet/netgroup.h                    |  2 +-
 nscd/aicache.c                     | 17 ++++------
 nscd/gai.c                         |  2 +-
 nscd/initgrcache.c                 |  8 ++---
 nscd/netgroupcache.c               |  4 +--
 nscd/nscd_netgroup.c               |  2 +-
 nss/XXX-lookup.c                   |  7 ++--
 nss/compat-lookup.c                |  8 ++---
 nss/getXXbyYY_r.c                  | 51 +++---------------------------
 nss/getXXent_r.c                   | 10 +++---
 nss/getnssent_r.c                  | 22 ++++++-------
 nss/nss_compat/compat-grp.c        |  2 +-
 nss/nss_compat/compat-initgroups.c |  2 +-
 nss/nss_compat/compat-pwd.c        |  2 +-
 nss/nss_compat/compat-spwd.c       |  2 +-
 posix/tst-rfc3484-2.c              |  2 +-
 posix/tst-rfc3484-3.c              |  2 +-
 posix/tst-rfc3484.c                |  2 +-
 sunrpc/netname.c                   | 21 ++----------
 sunrpc/publickey.c                 | 42 +++---------------------
 sysdeps/posix/getaddrinfo.c        | 19 ++++-------
 26 files changed, 88 insertions(+), 262 deletions(-)

Comments

Siddhesh Poyarekar Dec. 4, 2020, 3:29 a.m. UTC | #1
On 12/4/20 2:04 AM, DJ Delorie via Libc-alpha wrote:
> 
> Stitch new ABI and types throughout all NSS callers.

Looks fine to me.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Andreas Schwab Feb. 15, 2021, 3:42 p.m. UTC | #2
This makes nss_compat non-functional.

Andreas.
diff mbox series

Patch

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;
diff --git a/inet/ether_hton.c b/inet/ether_hton.c
index ff6943fc35..cccae17f10 100644
--- a/inet/ether_hton.c
+++ b/inet/ether_hton.c
@@ -30,9 +30,7 @@  typedef int (*lookup_function) (const char *, struct etherent *, char *, int,
 int
 ether_hostton (const char *hostname, struct ether_addr *addr)
 {
-  static service_user *startp;
-  static lookup_function start_fct;
-  service_user *nip;
+  nss_action_list nip;
   union
   {
     lookup_function f;
@@ -42,22 +40,7 @@  ether_hostton (const char *hostname, struct ether_addr *addr)
   enum nss_status status = NSS_STATUS_UNAVAIL;
   struct etherent etherent;
 
-  if (startp == NULL)
-    {
-      no_more = __nss_ethers_lookup2 (&nip, "gethostton_r", NULL, &fct.ptr);
-      if (no_more)
-	startp = (service_user *) -1;
-      else
-	{
-	  startp = nip;
-	  start_fct = fct.f;
-	}
-    }
-  else
-    {
-      fct.f = start_fct;
-      no_more = (nip = startp) == (service_user *) -1;
-    }
+  no_more = __nss_ethers_lookup2 (&nip, "gethostton_r", NULL, &fct.ptr);
 
   while (no_more == 0)
     {
diff --git a/inet/ether_ntoh.c b/inet/ether_ntoh.c
index e409773601..5ef654292c 100644
--- a/inet/ether_ntoh.c
+++ b/inet/ether_ntoh.c
@@ -31,9 +31,7 @@  typedef int (*lookup_function) (const struct ether_addr *, struct etherent *,
 int
 ether_ntohost (char *hostname, const struct ether_addr *addr)
 {
-  static service_user *startp;
-  static lookup_function start_fct;
-  service_user *nip;
+  nss_action_list nip;
   union
   {
     lookup_function f;
@@ -43,22 +41,7 @@  ether_ntohost (char *hostname, const struct ether_addr *addr)
   enum nss_status status = NSS_STATUS_UNAVAIL;
   struct etherent etherent;
 
-  if (startp == NULL)
-    {
-      no_more = __nss_ethers_lookup2 (&nip, "getntohost_r", NULL, &fct.ptr);
-      if (no_more)
-	startp = (service_user *) -1;
-      else
-	{
-	  startp = nip;
-	  start_fct = fct.f;
-	}
-    }
-  else
-    {
-      fct.f = start_fct;
-      no_more = (nip = startp) == (service_user *) -1;
-    }
+  no_more = __nss_ethers_lookup2 (&nip, "getntohost_r", NULL, &fct.ptr);
 
   while (no_more == 0)
     {
diff --git a/inet/getnetgrent_r.c b/inet/getnetgrent_r.c
index 78a66eee00..9c75af6f77 100644
--- a/inet/getnetgrent_r.c
+++ b/inet/getnetgrent_r.c
@@ -39,40 +39,12 @@  static struct __netgrent dataset;
 /* Set up NIP to run through the services.  Return nonzero if there are no
    services (left).  */
 static int
-setup (void **fctp, service_user **nipp)
+setup (void **fctp, nss_action_list *nipp)
 {
-  /* Remember the first service_entry, it's always the same.  */
-  static bool startp_initialized;
-  static service_user *startp;
   int no_more;
 
-  if (!startp_initialized)
-    {
-      /* Executing this more than once at the same time must yield the
-	 same result every time.  So we need no locking.  */
-      no_more = __nss_netgroup_lookup2 (nipp, "setnetgrent", NULL, fctp);
-      startp = no_more ? (service_user *) -1 : *nipp;
-#ifdef PTR_MANGLE
-      PTR_MANGLE (startp);
-#endif
-      atomic_write_barrier ();
-      startp_initialized = true;
-    }
-  else
-    {
-      service_user *nip = startp;
-#ifdef PTR_DEMANGLE
-      PTR_DEMANGLE (nip);
-#endif
-      if (nip == (service_user *) -1)
-	/* No services at all.  */
-	return 1;
-
-      /* Reset to the beginning of the service list.  */
-      *nipp = nip;
-      /* Look up the first function.  */
-      no_more = __nss_lookup (nipp, "setnetgrent", NULL, fctp);
-    }
+  no_more = __nss_netgroup_lookup2 (nipp, "setnetgrent", NULL, fctp);
+
   return no_more;
 }
 
@@ -100,7 +72,7 @@  endnetgrent_hook (struct __netgrent *datap)
 {
   enum nss_status (*endfct) (struct __netgrent *);
 
-  if (datap->nip == NULL || datap->nip == (service_user *) -1l)
+  if (datap->nip == NULL || datap->nip == (nss_action_list) -1l)
     return;
 
   endfct = __nss_lookup_function (datap->nip, "endnetgrent");
@@ -133,7 +105,7 @@  __internal_setnetgrent_reuse (const char *group, struct __netgrent *datap,
       /* Ignore status, we force check in `__nss_next2'.  */
       status = DL_CALL_FCT (*fct.f, (group, datap));
 
-      service_user *old_nip = datap->nip;
+      nss_action_list old_nip = datap->nip;
       no_more = __nss_next2 (&datap->nip, "setnetgrent", NULL, &fct.ptr,
 			     status, 0);
 
@@ -275,7 +247,7 @@  __internal_getnetgrent_r (char **hostp, char **userp, char **domainp,
       /* This bogus function pointer is a special marker left by
 	 __nscd_setnetgrent to tell us to use the data it left
 	 before considering any modules.  */
-      if (datap->nip == (service_user *) -1l)
+      if (datap->nip == (nss_action_list) -1l)
 	fct = nscd_getnetgrent;
       else
 #endif
diff --git a/inet/netgroup.h b/inet/netgroup.h
index 53081db78f..910094b9ca 100644
--- a/inet/netgroup.h
+++ b/inet/netgroup.h
@@ -64,7 +64,7 @@  struct __netgrent
 
   /* This handle for the NSS data base is shared between all
      set/get/endXXXent functions.  */
-  service_user *nip;
+  struct nss_action *nip;
 };
 
 
diff --git a/nscd/aicache.c b/nscd/aicache.c
index ee9c9b8843..a15ea751a7 100644
--- a/nscd/aicache.c
+++ b/nscd/aicache.c
@@ -71,20 +71,15 @@  addhstaiX (struct database_dyn *db, int fd, request_header *req,
 	dbg_log (_("Reloading \"%s\" in hosts cache!"), (char *) key);
     }
 
-  static service_user *hosts_database;
-  service_user *nip;
+  nss_action_list nip;
   int no_more;
   int rc6 = 0;
   int rc4 = 0;
   int herrno = 0;
 
-  if (hosts_database == NULL)
-    no_more = __nss_database_lookup2 ("hosts", NULL,
-				      "dns [!UNAVAIL=return] files",
-				      &hosts_database);
-  else
-    no_more = 0;
-  nip = hosts_database;
+  no_more = __nss_database_lookup2 ("hosts", NULL,
+				    "dns [!UNAVAIL=return] files",
+				    &nip);
 
   /* Initialize configurations.  */
   struct resolv_context *ctx = __resolv_context_get ();
@@ -442,10 +437,10 @@  next_nip:
       if (nss_next_action (nip, status[1]) == NSS_ACTION_RETURN)
 	break;
 
-      if (nip->next == NULL)
+      if (nip[1].module == NULL)
 	no_more = -1;
       else
-	nip = nip->next;
+	++nip;
     }
 
   /* No result found.  Create a negative result record.  */
diff --git a/nscd/gai.c b/nscd/gai.c
index b0058bc873..1b5dc94c0e 100644
--- a/nscd/gai.c
+++ b/nscd/gai.c
@@ -48,4 +48,4 @@ 
 #include <check_native.c>
 
 /* Some variables normally defined in libc.  */
-service_user *__nss_hosts_database attribute_hidden;
+nss_action_list __nss_hosts_database attribute_hidden;
diff --git a/nscd/initgrcache.c b/nscd/initgrcache.c
index a1102e4e46..0436421250 100644
--- a/nscd/initgrcache.c
+++ b/nscd/initgrcache.c
@@ -77,8 +77,8 @@  addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
 	dbg_log (_("Reloading \"%s\" in group cache!"), (char *) key);
     }
 
-  static service_user *group_database;
-  service_user *nip;
+  static nss_action_list group_database;
+  nss_action_list nip;
   int no_more;
 
   if (group_database == NULL)
@@ -161,10 +161,10 @@  addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
 	  && nss_next_action (nip, status) == NSS_ACTION_RETURN)
 	 break;
 
-      if (nip->next == NULL)
+      if (nip[1].module == NULL)
 	no_more = -1;
       else
-	nip = nip->next;
+	++nip;
     }
 
   bool all_written;
diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c
index 88c69d1e9c..67be24e837 100644
--- a/nscd/netgroupcache.c
+++ b/nscd/netgroupcache.c
@@ -124,7 +124,7 @@  addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
 	dbg_log (_("Reloading \"%s\" in netgroup cache!"), key);
     }
 
-  static service_user *netgroup_database;
+  static nss_action_list netgroup_database;
   time_t timeout;
   struct dataset *dataset;
   bool cacheable = false;
@@ -175,7 +175,7 @@  addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
 	void *ptr;
       } setfct;
 
-      service_user *nip = netgroup_database;
+      nss_action_list nip = netgroup_database;
       int no_more = __nss_lookup (&nip, "setnetgrent", NULL, &setfct.ptr);
       while (!no_more)
 	{
diff --git a/nscd/nscd_netgroup.c b/nscd/nscd_netgroup.c
index 7b8dc4081a..0ed9c0cda6 100644
--- a/nscd/nscd_netgroup.c
+++ b/nscd/nscd_netgroup.c
@@ -116,7 +116,7 @@  __nscd_setnetgrent (const char *group, struct __netgrent *datap)
       datap->data_size = datalen;
       datap->cursor = respdata;
       datap->first = 1;
-      datap->nip = (service_user *) -1l;
+      datap->nip = (nss_action_list) -1l;
       datap->known_groups = NULL;
       datap->needed_groups = NULL;
 
diff --git a/nss/XXX-lookup.c b/nss/XXX-lookup.c
index e26c6d7f8b..8ebd9a740a 100644
--- a/nss/XXX-lookup.c
+++ b/nss/XXX-lookup.c
@@ -53,12 +53,11 @@ 
 #endif
 
 int
-DB_LOOKUP_FCT (service_user **ni, const char *fct_name, const char *fct2_name,
+DB_LOOKUP_FCT (nss_action_list *ni, const char *fct_name, const char *fct2_name,
 	       void **fctp)
 {
-  if (DATABASE_NAME_SYMBOL == NULL
-      && __nss_database_lookup2 (DATABASE_NAME_STRING, ALTERNATE_NAME_STRING,
-				 DEFAULT_CONFIG, &DATABASE_NAME_SYMBOL) < 0)
+  if (__nss_database_lookup2 (DATABASE_NAME_STRING, ALTERNATE_NAME_STRING,
+			      DEFAULT_CONFIG, &DATABASE_NAME_SYMBOL) < 0)
     return -1;
 
   *ni = DATABASE_NAME_SYMBOL;
diff --git a/nss/compat-lookup.c b/nss/compat-lookup.c
index 9af34150bd..07fcc94f58 100644
--- a/nss/compat-lookup.c
+++ b/nss/compat-lookup.c
@@ -29,7 +29,7 @@ 
    glibc 2.7 and earlier and glibc 2.8 and later, even on i386.  */
 int
 attribute_compat_text_section
-__nss_passwd_lookup (service_user **ni, const char *fct_name, void **fctp)
+__nss_passwd_lookup (nss_action_list *ni, const char *fct_name, void **fctp)
 {
   __set_errno (ENOSYS);
   return -1;
@@ -46,11 +46,11 @@  compat_symbol (libc, __nss_hosts_lookup, __nss_hosts_lookup, GLIBC_2_0);
 
 /* These functions were exported under a non-GLIBC_PRIVATE version,
    even though it is not usable externally due to the service_user
-   type dependency.  */
+   (now nss_action_list) type dependency.  */
 
 int
 attribute_compat_text_section
-__nss_next (service_user **ni, const char *fct_name, void **fctp, int status,
+__nss_next (nss_action_list *ni, const char *fct_name, void **fctp, int status,
             int all_values)
 {
   return -1;
@@ -60,7 +60,7 @@  compat_symbol (libc, __nss_next, __nss_next, GLIBC_2_0);
 int
 attribute_compat_text_section
 __nss_database_lookup (const char *database, const char *alternate_name,
-                       const char *defconfig, service_user **ni)
+                       const char *defconfig, nss_action_list *ni)
 {
   *ni = NULL;
   return -1;
diff --git a/nss/getXXbyYY_r.c b/nss/getXXbyYY_r.c
index e8c9ab1bb3..6c287a6127 100644
--- a/nss/getXXbyYY_r.c
+++ b/nss/getXXbyYY_r.c
@@ -179,7 +179,7 @@  typedef enum nss_status (*lookup_function) (ADD_PARAMS, LOOKUP_TYPE *, char *,
 					    EXTRA_PARAMS);
 
 /* The lookup function for the first entry of this service.  */
-extern int DB_LOOKUP_FCT (service_user **nip, const char *name,
+extern int DB_LOOKUP_FCT (nss_action_list *nip, const char *name,
 			  const char *name2, void **fctp);
 libc_hidden_proto (DB_LOOKUP_FCT)
 
@@ -189,10 +189,7 @@  INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
 			   size_t buflen, LOOKUP_TYPE **result H_ERRNO_PARM
 			   EXTRA_PARAMS)
 {
-  static bool startp_initialized;
-  static service_user *startp;
-  static lookup_function start_fct;
-  service_user *nip;
+  nss_action_list nip;
   int do_merge = 0;
   LOOKUP_TYPE mergegrp;
   char *mergebuf = NULL;
@@ -227,6 +224,7 @@  INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
   PREPROCESS;
 #endif
 
+
 #ifdef HANDLE_DIGITS_DOTS
   switch (__nss_hostname_digits_dots (name, resbuf, &buffer, NULL,
 				      buflen, result, &status, AF_VAL,
@@ -264,47 +262,8 @@  INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
     }
 #endif
 
-  if (! startp_initialized)
-    {
-      no_more = DB_LOOKUP_FCT (&nip, REENTRANT_NAME_STRING,
-			       REENTRANT2_NAME_STRING, &fct.ptr);
-      if (no_more)
-	{
-	  void *tmp_ptr = (service_user *) -1l;
-#ifdef PTR_MANGLE
-	  PTR_MANGLE (tmp_ptr);
-#endif
-	  startp = tmp_ptr;
-	}
-      else
-	{
-	  void *tmp_ptr = fct.l;
-#ifdef PTR_MANGLE
-	  PTR_MANGLE (tmp_ptr);
-#endif
-	  start_fct = tmp_ptr;
-	  tmp_ptr = nip;
-#ifdef PTR_MANGLE
-	  PTR_MANGLE (tmp_ptr);
-#endif
-	  startp = tmp_ptr;
-	}
-
-      /* Make sure start_fct and startp are written before
-	 startp_initialized.  */
-      atomic_write_barrier ();
-      startp_initialized = true;
-    }
-  else
-    {
-      fct.l = start_fct;
-      nip = startp;
-#ifdef PTR_DEMANGLE
-      PTR_DEMANGLE (fct.l);
-      PTR_DEMANGLE (nip);
-#endif
-      no_more = nip == (service_user *) -1l;
-    }
+  no_more = DB_LOOKUP_FCT (&nip, REENTRANT_NAME_STRING,
+			   REENTRANT2_NAME_STRING, &fct.ptr);
 
   while (no_more == 0)
     {
diff --git a/nss/getXXent_r.c b/nss/getXXent_r.c
index 8b64fcd795..dfcbd01f66 100644
--- a/nss/getXXent_r.c
+++ b/nss/getXXent_r.c
@@ -95,11 +95,11 @@ 
 
 /* This handle for the NSS data base is shared between all
    set/get/endXXXent functions.  */
-static service_user *nip;
+static nss_action_list nip;
 /* Remember the last service used since the last call to  `endXXent'.  */
-static service_user *last_nip;
-/* Remember the first service_entry, it's always the same.  */
-static service_user *startp;
+static nss_action_list last_nip;
+/* Remember the first service_entry across set/get/endent.  */
+static nss_action_list startp;
 
 #ifdef STAYOPEN_TMP
 /* We need to remember the last `stayopen' flag given by the user
@@ -112,7 +112,7 @@  static STAYOPEN_TMP;
 __libc_lock_define_initialized (static, lock)
 
 /* The lookup function for the first entry of this service.  */
-extern int DB_LOOKUP_FCT (service_user **nip, const char *name,
+extern int DB_LOOKUP_FCT (nss_action_list *nip, const char *name,
 			  const char *name2, void **fctp);
 libc_hidden_proto (DB_LOOKUP_FCT)
 
diff --git a/nss/getnssent_r.c b/nss/getnssent_r.c
index 8a366bc7ea..84e977c33b 100644
--- a/nss/getnssent_r.c
+++ b/nss/getnssent_r.c
@@ -25,20 +25,20 @@ 
    services (left).  */
 static int
 setup (const char *func_name, db_lookup_function lookup_fct,
-       void **fctp, service_user **nip, service_user **startp, int all)
+       void **fctp, nss_action_list *nip, nss_action_list *startp, int all)
 {
   int no_more;
-  if (*startp == NULL)
+  if (*startp == NULL || all)
     {
       no_more = lookup_fct (nip, func_name, NULL, fctp);
-      *startp = no_more ? (service_user *) -1l : *nip;
+      *startp = no_more ? (nss_action_list) -1l : *nip;
     }
-  else if (*startp == (service_user *) -1l)
+  else if (*startp == (nss_action_list) -1l)
     /* No services at all.  */
     return 1;
   else
     {
-      if (all || !*nip)
+      if (!*nip)
 	/* Reset to the beginning of the service list.  */
 	*nip = *startp;
       /* Look up the first function.  */
@@ -49,8 +49,8 @@  setup (const char *func_name, db_lookup_function lookup_fct,
 
 void
 __nss_setent (const char *func_name, db_lookup_function lookup_fct,
-	      service_user **nip, service_user **startp,
-	      service_user **last_nip, int stayopen, int *stayopen_tmp,
+	      nss_action_list *nip, nss_action_list *startp,
+	      nss_action_list *last_nip, int stayopen, int *stayopen_tmp,
 	      int res)
 {
   union
@@ -110,8 +110,8 @@  __nss_setent (const char *func_name, db_lookup_function lookup_fct,
 
 void
 __nss_endent (const char *func_name, db_lookup_function lookup_fct,
-	      service_user **nip, service_user **startp,
-	      service_user **last_nip, int res)
+	      nss_action_list *nip, nss_action_list *startp,
+	      nss_action_list *last_nip, int res)
 {
   union
   {
@@ -154,8 +154,8 @@  int
 __nss_getent_r (const char *getent_func_name,
 		const char *setent_func_name,
 		db_lookup_function lookup_fct,
-		service_user **nip, service_user **startp,
-		service_user **last_nip, int *stayopen_tmp, int res,
+		nss_action_list *nip, nss_action_list *startp,
+		nss_action_list *last_nip, int *stayopen_tmp, int res,
 		void *resbuf, char *buffer, size_t buflen,
 		void **result, int *h_errnop)
 {
diff --git a/nss/nss_compat/compat-grp.c b/nss/nss_compat/compat-grp.c
index 510d49e8c7..6637c96355 100644
--- a/nss/nss_compat/compat-grp.c
+++ b/nss/nss_compat/compat-grp.c
@@ -30,7 +30,7 @@ 
 
 NSS_DECLARE_MODULE_FUNCTIONS (compat)
 
-static service_user *ni;
+static nss_action_list ni;
 static enum nss_status (*setgrent_impl) (int stayopen);
 static enum nss_status (*getgrnam_r_impl) (const char *name,
 					   struct group * grp, char *buffer,
diff --git a/nss/nss_compat/compat-initgroups.c b/nss/nss_compat/compat-initgroups.c
index c0dcdf839d..99f7df613a 100644
--- a/nss/nss_compat/compat-initgroups.c
+++ b/nss/nss_compat/compat-initgroups.c
@@ -33,7 +33,7 @@ 
 
 NSS_DECLARE_MODULE_FUNCTIONS (compat)
 
-static service_user *ni;
+static nss_action_list ni;
 static enum nss_status (*initgroups_dyn_impl) (const char *, gid_t,
 					       long int *, long int *,
 					       gid_t **, long int, int *);
diff --git a/nss/nss_compat/compat-pwd.c b/nss/nss_compat/compat-pwd.c
index 3a212a0dab..789878ccbd 100644
--- a/nss/nss_compat/compat-pwd.c
+++ b/nss/nss_compat/compat-pwd.c
@@ -34,7 +34,7 @@ 
 
 NSS_DECLARE_MODULE_FUNCTIONS (compat)
 
-static service_user *ni;
+static nss_action_list ni;
 static enum nss_status (*setpwent_impl) (int stayopen);
 static enum nss_status (*getpwnam_r_impl) (const char *name,
 					   struct passwd * pwd, char *buffer,
diff --git a/nss/nss_compat/compat-spwd.c b/nss/nss_compat/compat-spwd.c
index d802ee0302..7310da85bd 100644
--- a/nss/nss_compat/compat-spwd.c
+++ b/nss/nss_compat/compat-spwd.c
@@ -34,7 +34,7 @@ 
 
 NSS_DECLARE_MODULE_FUNCTIONS (compat)
 
-static service_user *ni;
+static nss_action_list ni;
 static enum nss_status (*setspent_impl) (int stayopen);
 static enum nss_status (*getspnam_r_impl) (const char *name, struct spwd * sp,
 					   char *buffer, size_t buflen,
diff --git a/posix/tst-rfc3484-2.c b/posix/tst-rfc3484-2.c
index 8c64ac59ff..5f5ada9420 100644
--- a/posix/tst-rfc3484-2.c
+++ b/posix/tst-rfc3484-2.c
@@ -58,7 +58,7 @@  _res_hconf_init (void)
 #undef	USE_NSCD
 #include "../sysdeps/posix/getaddrinfo.c"
 
-service_user *__nss_hosts_database attribute_hidden;
+nss_action_list __nss_hosts_database attribute_hidden;
 
 /* This is the beginning of the real test code.  The above defines
    (among other things) the function rfc3484_sort.  */
diff --git a/posix/tst-rfc3484-3.c b/posix/tst-rfc3484-3.c
index 1c61aaf844..d9ec5cc851 100644
--- a/posix/tst-rfc3484-3.c
+++ b/posix/tst-rfc3484-3.c
@@ -58,7 +58,7 @@  _res_hconf_init (void)
 #undef	USE_NSCD
 #include "../sysdeps/posix/getaddrinfo.c"
 
-service_user *__nss_hosts_database attribute_hidden;
+nss_action_list __nss_hosts_database attribute_hidden;
 
 /* This is the beginning of the real test code.  The above defines
    (among other things) the function rfc3484_sort.  */
diff --git a/posix/tst-rfc3484.c b/posix/tst-rfc3484.c
index 8f45848e44..97d065b6bf 100644
--- a/posix/tst-rfc3484.c
+++ b/posix/tst-rfc3484.c
@@ -58,7 +58,7 @@  _res_hconf_init (void)
 #undef	USE_NSCD
 #include "../sysdeps/posix/getaddrinfo.c"
 
-service_user *__nss_hosts_database attribute_hidden;
+nss_action_list __nss_hosts_database attribute_hidden;
 
 /* This is the beginning of the real test code.  The above defines
    (among other things) the function rfc3484_sort.  */
diff --git a/sunrpc/netname.c b/sunrpc/netname.c
index 24ee519e42..c0073be6d2 100644
--- a/sunrpc/netname.c
+++ b/sunrpc/netname.c
@@ -145,9 +145,7 @@  int
 netname2user (const char *netname, uid_t * uidp, gid_t * gidp,
 	      int *gidlenp, gid_t * gidlist)
 {
-  static service_user *startp;
-  static netname2user_function start_fct;
-  service_user *nip;
+  nss_action_list nip;
   union
   {
     netname2user_function f;
@@ -156,22 +154,7 @@  netname2user (const char *netname, uid_t * uidp, gid_t * gidp,
   enum nss_status status = NSS_STATUS_UNAVAIL;
   int no_more;
 
-  if (startp == NULL)
-    {
-      no_more = __nss_publickey_lookup2 (&nip, "netname2user", NULL, &fct.ptr);
-      if (no_more)
-	startp = (service_user *) - 1;
-      else
-	{
-	  startp = nip;
-	  start_fct = fct.f;
-	}
-    }
-  else
-    {
-      fct.f = start_fct;
-      no_more = (nip = startp) == (service_user *) - 1;
-    }
+  no_more = __nss_publickey_lookup2 (&nip, "netname2user", NULL, &fct.ptr);
 
   while (!no_more)
     {
diff --git a/sunrpc/publickey.c b/sunrpc/publickey.c
index 2fa0252d5b..63866ef900 100644
--- a/sunrpc/publickey.c
+++ b/sunrpc/publickey.c
@@ -34,9 +34,7 @@  typedef int (*secret_function) (const char *, char *, const char *, int *);
 int
 getpublickey (const char *name, char *key)
 {
-  static service_user *startp;
-  static public_function start_fct;
-  service_user *nip;
+  nss_action_list nip;
   union
   {
     public_function f;
@@ -45,22 +43,7 @@  getpublickey (const char *name, char *key)
   enum nss_status status = NSS_STATUS_UNAVAIL;
   int no_more;
 
-  if (startp == NULL)
-    {
-      no_more = __nss_publickey_lookup2 (&nip, "getpublickey", NULL, &fct.ptr);
-      if (no_more)
-	startp = (service_user *) -1;
-      else
-	{
-	  startp = nip;
-	  start_fct = fct.f;
-	}
-    }
-  else
-    {
-      fct.f = start_fct;
-      no_more = (nip = startp) == (service_user *) -1;
-    }
+  no_more = __nss_publickey_lookup2 (&nip, "getpublickey", NULL, &fct.ptr);
 
   while (! no_more)
     {
@@ -77,9 +60,7 @@  libc_hidden_nolink_sunrpc (getpublickey, GLIBC_2_0)
 int
 getsecretkey (const char *name, char *key, const char *passwd)
 {
-  static service_user *startp;
-  static secret_function start_fct;
-  service_user *nip;
+  nss_action_list nip;
   union
   {
     secret_function f;
@@ -88,22 +69,7 @@  getsecretkey (const char *name, char *key, const char *passwd)
   enum nss_status status = NSS_STATUS_UNAVAIL;
   int no_more;
 
-  if (startp == NULL)
-    {
-      no_more = __nss_publickey_lookup2 (&nip, "getsecretkey", NULL, &fct.ptr);
-      if (no_more)
-	startp = (service_user *) -1;
-      else
-	{
-	  startp = nip;
-	  start_fct = fct.f;
-	}
-    }
-  else
-    {
-      fct.f = start_fct;
-      no_more = (nip = startp) == (service_user *) -1;
-    }
+  no_more = __nss_publickey_lookup2 (&nip, "getsecretkey", NULL, &fct.ptr);
 
   while (! no_more)
     {
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index ad4923ddbc..a3097f8bce 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -307,7 +307,7 @@  convert_hostent_to_gaih_addrtuple (const struct addrinfo *req,
    memory allocation failure.  The returned string is allocated on the
    heap; the caller has to free it.  */
 static char *
-getcanonname (service_user *nip, struct gaih_addrtuple *at, const char *name)
+getcanonname (nss_action_list nip, struct gaih_addrtuple *at, const char *name)
 {
   nss_getcanonname_r *cfct = __nss_lookup_function (nip, "getcanonname_r");
   char *s = (char *) name;
@@ -538,7 +538,7 @@  gaih_inet (const char *name, const struct gaih_service *service,
 	  struct gaih_addrtuple **pat = &at;
 	  int no_data = 0;
 	  int no_inet6_data = 0;
-	  service_user *nip;
+	  nss_action_list nip;
 	  enum nss_status inet6_status = NSS_STATUS_UNAVAIL;
 	  enum nss_status status = NSS_STATUS_UNAVAIL;
 	  int no_more;
@@ -720,13 +720,9 @@  gaih_inet (const char *name, const struct gaih_service *service,
 	    }
 #endif
 
-	  if (__nss_hosts_database == NULL)
-	    no_more = __nss_database_lookup2 ("hosts", NULL,
-					      "dns [!UNAVAIL=return] files",
-					      &__nss_hosts_database);
-	  else
-	    no_more = 0;
-	  nip = __nss_hosts_database;
+	  no_more = __nss_database_lookup2 ("hosts", NULL,
+					    "dns [!UNAVAIL=return] files",
+					    &nip);
 
 	  /* If we are looking for both IPv4 and IPv6 address we don't
 	     want the lookup functions to automatically promote IPv4
@@ -905,10 +901,9 @@  gaih_inet (const char *name, const struct gaih_service *service,
 	      if (nss_next_action (nip, status) == NSS_ACTION_RETURN)
 		break;
 
-	      if (nip->next == NULL)
+	      nip++;
+	      if (nip->module == NULL)
 		no_more = -1;
-	      else
-		nip = nip->next;
 	    }
 
 	  __resolv_context_put (res_ctx);