]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nsswitch: use new internal API (callers)
authorDJ Delorie <dj@redhat.com>
Tue, 10 Nov 2020 03:09:34 +0000 (22:09 -0500)
committerDJ Delorie <dj@redhat.com>
Fri, 4 Dec 2020 22:16:32 +0000 (17:16 -0500)
Stitch new ABI and types throughout all NSS callers.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
26 files changed:
grp/compat-initgroups.c
grp/initgroups.c
inet/ether_hton.c
inet/ether_ntoh.c
inet/getnetgrent_r.c
inet/netgroup.h
nscd/aicache.c
nscd/gai.c
nscd/initgrcache.c
nscd/netgroupcache.c
nscd/nscd_netgroup.c
nss/XXX-lookup.c
nss/compat-lookup.c
nss/getXXbyYY_r.c
nss/getXXent_r.c
nss/getnssent_r.c
nss/nss_compat/compat-grp.c
nss/nss_compat/compat-initgroups.c
nss/nss_compat/compat-pwd.c
nss/nss_compat/compat-spwd.c
posix/tst-rfc3484-2.c
posix/tst-rfc3484-3.c
posix/tst-rfc3484.c
sunrpc/netname.c
sunrpc/publickey.c
sysdeps/posix/getaddrinfo.c

index 3dd50d23064f46d4e81e05ee6f856db273005a4a..9df940767be8a17ae80da817f616c5571c0195a5 100644 (file)
@@ -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;
index 0c17141117e6c3b33b20ed2950dc80f99b1ee663..a60ca1c39553142151075d5a114902f9376f0d3f 100644 (file)
@@ -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;
index ff6943fc359732f0e19d380682fd6b8ca48e6a52..cccae17f107779bc95b5b3ba7ec88e5d819a5543 100644 (file)
@@ -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)
     {
index e409773601ba62ca18cffd3cda2c322ed05c88f1..5ef654292c78f797e9020893160cc045227cd3d4 100644 (file)
@@ -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)
     {
index 78a66eee00231f5f3c8ace6c5816852b90bd8106..9c75af6f771ffd4c2ace56c54b255988b67d7c36 100644 (file)
@@ -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;
 }
 \f
@@ -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
index 53081db78f1b738a0637e1b2db9c99d97e3cbe68..910094b9cabe5494d993b4c9e801303f8a0a2e7c 100644 (file)
@@ -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;
 };
 
 
index ee9c9b884339387850d9d1dc75d3d83235ad3e30..a15ea751a767edb1e23e528b6c73be7861ba7096 100644 (file)
@@ -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.  */
index b0058bc873509fa5fef2f7a11052d4370e4c01b4..1b5dc94c0e17c6fb5efa605c864468ede74d1c2d 100644 (file)
@@ -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;
index a1102e4e4604e42c13a154a6476460d672428a59..043642125019b2db21f9e359d725356b6d6f9cbc 100644 (file)
@@ -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;
index 88c69d1e9c1d183eccb8e443e43b3f42add0602d..67be24e837e3dd899c193e02a18cda666a7a9622 100644 (file)
@@ -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)
        {
index 7b8dc4081a443c66e2a92bab6cb8b1397562ff5e..0ed9c0cda6d221c432b45ccc61ea6add7883c50a 100644 (file)
@@ -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;
 
index e26c6d7f8b822465de57625858ab5475ccff1227..8ebd9a740a44b0761c8779e8dc67c792dcccdc6a 100644 (file)
 #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;
index 9af34150bd93c47588d173d782f2ee9ef3aaa6a4..07fcc94f580cf98990d079d782bbc04110b0c0c5 100644 (file)
@@ -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;
index e8c9ab1bb3edfe74eb9d484122c9479d5739b08b..6c287a61274231fdd18334755f6f2a2c79bb1c43 100644 (file)
@@ -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)
     {
index 8b64fcd79549d298d17d310204da9962cbdb278e..dfcbd01f660d0d1173f755b858d1a4721d0c7d81 100644 (file)
 
 /* 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)
 \f
index 8a366bc7eae270988643ab9ff18b6f76acef486c..84e977c33b0761ff571f8feba551cadb28e5e5bc 100644 (file)
    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,
 \f
 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)
 {
index 510d49e8c743641b3cd81363c667ed00c8357ab7..6637c96355aecaec5ce6c5b6fbf2e153748be2f1 100644 (file)
@@ -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,
index c0dcdf839d17d03bb52bb78609de910ab696bea9..99f7df613af330f5f7d4b96b97ad02e45023cb8c 100644 (file)
@@ -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 *);
index 3a212a0dab43cdb9455de3c768b7b901e606aa3e..789878ccbd0688432e460cba7369454ad6aa88d8 100644 (file)
@@ -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,
index d802ee0302e5269f2faf9c50c4b453452738d51b..7310da85bd97ea42eb95ff65548e127f98bcf035 100644 (file)
@@ -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,
index 8c64ac59ff5777ce3b7e0fb504415a75652808da..5f5ada9420831d02c184200cddb3c30be70b96e0 100644 (file)
@@ -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.  */
index 1c61aaf84484fba3458b6286dbb28d48f37e380e..d9ec5cc851492963e03c773c6dd3eefdc9dbf5e9 100644 (file)
@@ -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.  */
index 8f45848e44608f8fa94aa96e5ab87fede15d396a..97d065b6bf939dfdf8f31f490233936d3768298d 100644 (file)
@@ -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.  */
index 24ee519e42a3b51586f9f4c8158e9323a88a6c64..c0073be6d21674ef66436b31200125cae15454c2 100644 (file)
@@ -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)
     {
index 2fa0252d5b8239f90d91d8b7e80eccd636eb5222..63866ef900a0a6c830e24237c9c33779faeab67f 100644 (file)
@@ -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)
     {
index ad4923ddbc31390921a5ee4165b365dbd729d2d9..a3097f8bce4e6a78cd2f5b7452e8b9d99b114f51 100644 (file)
@@ -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);