summaryrefslogtreecommitdiff
path: root/inet
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-10-30 00:48:09 +0000
committerUlrich Drepper <drepper@redhat.com>2007-10-30 00:48:09 +0000
commit384ca551743318bd9c9e24a496d6397f2e3f2a49 (patch)
tree86803bb391775670bd8dece020a91ba870a202d4 /inet
parent53bab260f5a80da3c6900d03ae92d2f3ef28bacb (diff)
downloadglibc-384ca551743318bd9c9e24a496d6397f2e3f2a49.tar.gz
* nscd/Makefile (nscd-modules): Replace gethstbynm2_r with
gethstbynm3_r. * nscd/gethstbynm2_r.c: Remove. * nscd/gethstbynm3_r.c: New file. * nscd/aicache.c (addhstaiX): Use __gethostbyaddr2_r instead of __gethostbyaddr_r. * nscd/gethstbyad_r.c: Generate __gethostbyaddr2_r function. Define __gethostbyaddr_r compatibility wrapper. * nscd/hstcache.c (cache_addhst): Add ttl parameter. Use it when determining timeout of entry. (lookup): Take new parameter and pass it to __gethostbyname3_r and __gethostbyaddr2_r. (addhstbyX): Pass reference to variable for TTL to lookup and cache_addhst. * nss/Versions [glibc] (GLIBC_PRIVATE): Export __nss_passwd_lookup2, __nss_group_lookup2, __nss_hosts_lookup2, __nss_services_lookup2, and __nss_next2. Remove __nss_services_lookup. * nss/XXX-lookup.c: Name function now *_lookup2. Add new parameter. Add compat wrapper. * nss/getXXbyYY_r.c: Changes to call new *_lookup2 functions and __nss_next2. * nss/getXXent_r.c: Likewise. * nss/getnssent_r.c: Likewise. * nss/nsswitch.c (__nss_lookup): Add new parameter. If first function does not exist in module, try the optional second name. (__nss_next2): New function. (__nss_next): Now wrapper around __nss_next2. * nss/nsswitch.h: Adjust __nss_lookup prototype. Declare __nss_next2. Adjust definition of db_lookup_function type. * nss/service-lookup.c: Define NO_COMPAT. * include/netdb.h: Declare __gethostbyaddr2_r and __gethostbyname3_r. * inet/ether_hton.c: Use __nss_next2 instead of __nss_next. * inet/ether_ntoh.c: Likewise. * sunrpc/netname.c: Likewise. * sunrpc/publickey.c: Likewise. * inet/getnetgrent.c: Likewise. Adjust calls to __nss_lookup. * inet/gethstbyad_r.c (DB_LOOKUP_FCT): Change to __nss_hosts_lookup2. * inet/gethstbynm2_r.c (DB_LOOKUP_FCT): Likewise. * inet/gethstbynm_r.c (DB_LOOKUP_FCT): Likewise. * inet/gethstent_r.c (DB_LOOKUP_FCT): Likewise. * nscd/aicache.c (addhstaiX): Fix default TTL handling. * inet/getnetgrent.c (setup): Encrypt static pointer.
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)