about summary refs log tree commit diff
path: root/inet
diff options
context:
space:
mode:
Diffstat (limited to 'inet')
-rw-r--r--inet/ether_hton.c4
-rw-r--r--inet/ether_ntoh.c4
-rw-r--r--inet/gethstbyad_r.c4
-rw-r--r--inet/gethstbynm2_r.c4
-rw-r--r--inet/gethstbynm_r.c4
-rw-r--r--inet/gethstent_r.c4
-rw-r--r--inet/getnetgrent_r.c33
7 files changed, 34 insertions, 23 deletions
diff --git a/inet/ether_hton.c b/inet/ether_hton.c
index 64f5ab5d36..2bff47d472 100644
--- a/inet/ether_hton.c
+++ b/inet/ether_hton.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1999, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1999, 2002, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -71,7 +71,7 @@ ether_hostton (const char *hostname, struct ether_addr *addr)
 
       status = (*fct.f) (hostname, &etherent, buffer, sizeof buffer, &errno);
 
-      no_more = __nss_next (&nip, "gethostton_r", &fct.ptr, status, 0);
+      no_more = __nss_next2 (&nip, "gethostton_r", NULL, &fct.ptr, status, 0);
     }
 
   if (status == NSS_STATUS_SUCCESS)
diff --git a/inet/ether_ntoh.c b/inet/ether_ntoh.c
index ad4165cb3e..9bc26b9fb6 100644
--- a/inet/ether_ntoh.c
+++ b/inet/ether_ntoh.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1999, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996,1997,1999,2001,2002,2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -72,7 +72,7 @@ ether_ntohost (char *hostname, const struct ether_addr *addr)
 
       status = (*fct.f) (addr, &etherent, buffer, sizeof buffer, &errno);
 
-      no_more = __nss_next (&nip, "getntohost_r", &fct.ptr, status, 0);
+      no_more = __nss_next2 (&nip, "getntohost_r", NULL, &fct.ptr, status, 0);
     }
 
   if (status == NSS_STATUS_SUCCESS)
diff --git a/inet/gethstbyad_r.c b/inet/gethstbyad_r.c
index 020ac489ef..b1f0f496f1 100644
--- a/inet/gethstbyad_r.c
+++ b/inet/gethstbyad_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996,1997,1998,1999,2000,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2000,2002,2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -48,6 +48,6 @@
     }
 
 /* Special name for the lookup function.  */
-#define DB_LOOKUP_FCT __nss_hosts_lookup
+#define DB_LOOKUP_FCT __nss_hosts_lookup2
 
 #include "../nss/getXXbyYY_r.c"
diff --git a/inet/gethstbynm2_r.c b/inet/gethstbynm2_r.c
index e1e691b2b5..de33dfc93b 100644
--- a/inet/gethstbynm2_r.c
+++ b/inet/gethstbynm2_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2002, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -41,6 +41,6 @@
 #define HAVE_AF			1
 
 /* Special name for the lookup function.  */
-#define DB_LOOKUP_FCT __nss_hosts_lookup
+#define DB_LOOKUP_FCT __nss_hosts_lookup2
 
 #include "../nss/getXXbyYY_r.c"
diff --git a/inet/gethstbynm_r.c b/inet/gethstbynm_r.c
index 5bc65f1391..16cc194641 100644
--- a/inet/gethstbynm_r.c
+++ b/inet/gethstbynm_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 2002, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -40,6 +40,6 @@
 #define HAVE_LOOKUP_BUFFER	1
 
 /* Special name for the lookup function.  */
-#define DB_LOOKUP_FCT __nss_hosts_lookup
+#define DB_LOOKUP_FCT __nss_hosts_lookup2
 
 #include "../nss/getXXbyYY_r.c"
diff --git a/inet/gethstent_r.c b/inet/gethstent_r.c
index a7424a4188..943cf04550 100644
--- a/inet/gethstent_r.c
+++ b/inet/gethstent_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 2002, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -30,6 +30,6 @@
 #define NEED__RES	1
 
 /* Special name for the lookup function.  */
-#define DB_LOOKUP_FCT __nss_hosts_lookup
+#define DB_LOOKUP_FCT __nss_hosts_lookup2
 
 #include "../nss/getXXent_r.c"
diff --git a/inet/getnetgrent_r.c b/inet/getnetgrent_r.c
index 97b2b809f0..38701857cb 100644
--- a/inet/getnetgrent_r.c
+++ b/inet/getnetgrent_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 1999, 2002, 2004, 2005
+/* Copyright (C) 1996, 1997, 1998, 1999, 2002, 2004, 2005, 2007
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -18,13 +18,16 @@
    02111-1307 USA.  */
 
 #include <assert.h>
+#include <atomic.h>
 #include <bits/libc-lock.h>
 #include <errno.h>
 #include <netdb.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
 #include "netgroup.h"
 #include "nsswitch.h"
+#include <sysdep.h>
 
 
 /* Protect above variable against multiple uses at the same time.  */
@@ -44,25 +47,32 @@ static int
 setup (void **fctp, service_user **nipp)
 {
   /* Remember the first service_entry, it's always the same.  */
+  static bool startp_initialized;
   static service_user *startp;
   int no_more;
 
-  if (startp == NULL)
+  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_lookup (nipp, "setnetgrent", fctp);
       startp = no_more ? (service_user *) -1 : *nipp;
+      PTR_MANGLE (startp);
+      atomic_write_barrier ();
+      startp_initialized = true;
     }
-  else if (startp == (service_user *) -1)
-    /* No services at all.  */
-    return 1;
   else
     {
+      service_user *nip = startp;
+      PTR_DEMANGLE (nip);
+      if (nip == (service_user *) -1)
+	/* No services at all.  */
+	return 1;
+
       /* Reset to the beginning of the service list.  */
-      *nipp = startp;
+      *nipp = nip;
       /* Look up the first function.  */
-      no_more = __nss_lookup (nipp, "setnetgrent", fctp);
+      no_more = __nss_lookup (nipp, "setnetgrent", NULL, fctp);
     }
   return no_more;
 }
@@ -122,11 +132,12 @@ __internal_setnetgrent_reuse (const char *group, struct __netgrent *datap,
     {
       assert (datap->data == NULL);
 
-      /* Ignore status, we force check in `__nss_next'.  */
+      /* Ignore status, we force check in `__nss_next2'.  */
       status = (*fct.f) (group, datap);
 
       service_user *old_nip = datap->nip;
-      no_more = __nss_next (&datap->nip, "setnetgrent", &fct.ptr, status, 0);
+      no_more = __nss_next2 (&datap->nip, "setnetgrent", NULL, &fct.ptr,
+			     status, 0);
 
       if (status == NSS_STATUS_SUCCESS && ! no_more)
 	{
@@ -423,8 +434,8 @@ innetgr (const char *netgroup, const char *host, const char *user,
 	    break;
 
 	  /* Look for the next service.  */
-	  no_more = __nss_next (&entry.nip, "setnetgrent",
-				&setfct.ptr, status, 0);
+	  no_more = __nss_next2 (&entry.nip, "setnetgrent", NULL,
+				 &setfct.ptr, status, 0);
 	}
 
       if (result == 0 && entry.needed_groups != NULL)