aboutsummaryrefslogtreecommitdiff
path: root/nss/getXXbyYY_r.c
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 /nss/getXXbyYY_r.c
parent53bab260f5a80da3c6900d03ae92d2f3ef28bacb (diff)
downloadglibc-384ca551743318bd9c9e24a496d6397f2e3f2a49.zip
glibc-384ca551743318bd9c9e24a496d6397f2e3f2a49.tar.gz
glibc-384ca551743318bd9c9e24a496d6397f2e3f2a49.tar.bz2
* 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 'nss/getXXbyYY_r.c')
-rw-r--r--nss/getXXbyYY_r.c63
1 files changed, 46 insertions, 17 deletions
diff --git a/nss/getXXbyYY_r.c b/nss/getXXbyYY_r.c
index 6c90ba5..b535f67 100644
--- a/nss/getXXbyYY_r.c
+++ b/nss/getXXbyYY_r.c
@@ -42,12 +42,18 @@
|* DATABASE_NAME - name of the database the function accesses *|
|* (e.g., host, services, ...) *|
|* *|
-|* ADD_PARAMS - additional parameter, can vary in number *|
+|* ADD_PARAMS - additional parameters, can vary in number *|
|* *|
-|* ADD_VARIABLES - names of additional parameter *|
+|* ADD_VARIABLES - names of additional parameters *|
|* *|
|* Optionally the following vars can be defined: *|
|* *|
+|* EXTRA_PARAMS - optional parameters, can vary in number *|
+|* *|
+|* EXTRA_VARIABLES - names of optional parameter *|
+|* *|
+|* FUNCTION_NAME - alternative name of the non-reentrant function *|
+|* *|
|* NEED_H_ERRNO - an extra parameter will be passed to point to *|
|* the global `h_errno' variable. *|
|* *|
@@ -62,6 +68,11 @@
/* To make the real sources a bit prettier. */
#define REENTRANT_NAME APPEND_R (FUNCTION_NAME)
+#ifdef FUNCTION2_NAME
+# define REENTRANT2_NAME APPEND_R (FUNCTION2_NAME)
+#else
+# define REENTRANT2_NAME NULL
+#endif
#define APPEND_R(name) APPEND_R1 (name)
#define APPEND_R1(name) name##_r
#define INTERNAL(name) INTERNAL1 (name)
@@ -80,12 +91,17 @@
#define FUNCTION_NAME_STRING STRINGIZE (FUNCTION_NAME)
#define REENTRANT_NAME_STRING STRINGIZE (REENTRANT_NAME)
+#ifdef FUNCTION2_NAME
+# define REENTRANT2_NAME_STRING STRINGIZE (REENTRANT2_NAME)
+#else
+# define REENTRANT2_NAME_STRING NULL
+#endif
#define DATABASE_NAME_STRING STRINGIZE (DATABASE_NAME)
#define STRINGIZE(name) STRINGIZE1 (name)
#define STRINGIZE1(name) #name
#ifndef DB_LOOKUP_FCT
-# define DB_LOOKUP_FCT CONCAT3_1 (__nss_, DATABASE_NAME, _lookup)
+# define DB_LOOKUP_FCT CONCAT3_1 (__nss_, DATABASE_NAME, _lookup2)
# define CONCAT3_1(Pre, Name, Post) CONCAT3_2 (Pre, Name, Post)
# define CONCAT3_2(Pre, Name, Post) Pre##Name##Post
#endif
@@ -101,6 +117,13 @@
# define H_ERRNO_VAR_P NULL
#endif
+#ifndef EXTRA_PARAMS
+# define EXTRA_PARAMS
+#endif
+#ifndef EXTRA_VARIABLES
+# define EXTRA_VARIABLES
+#endif
+
#ifdef HAVE_AF
# define AF_VAL af
#else
@@ -109,17 +132,20 @@
/* Type of the lookup function we need here. */
typedef enum nss_status (*lookup_function) (ADD_PARAMS, LOOKUP_TYPE *, char *,
- size_t, int * H_ERRNO_PARM);
+ size_t, int * H_ERRNO_PARM
+ EXTRA_PARAMS);
/* The lookup function for the first entry of this service. */
-extern int DB_LOOKUP_FCT (service_user **nip, const char *name, void **fctp)
+extern int DB_LOOKUP_FCT (service_user **nip, const char *name,
+ const char *name2, void **fctp)
internal_function;
libc_hidden_proto (DB_LOOKUP_FCT)
int
INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
- size_t buflen, LOOKUP_TYPE **result H_ERRNO_PARM)
+ size_t buflen, LOOKUP_TYPE **result H_ERRNO_PARM
+ EXTRA_PARAMS)
{
static bool startp_initialized;
static service_user *startp;
@@ -171,7 +197,8 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
if (! startp_initialized)
{
- no_more = DB_LOOKUP_FCT (&nip, REENTRANT_NAME_STRING, &fct.ptr);
+ no_more = DB_LOOKUP_FCT (&nip, REENTRANT_NAME_STRING,
+ REENTRANT2_NAME_STRING, &fct.ptr);
if (no_more)
{
void *tmp_ptr = (service_user *) -1l;
@@ -224,7 +251,7 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
#endif
status = DL_CALL_FCT (fct.l, (ADD_VARIABLES, resbuf, buffer, buflen,
- &errno H_ERRNO_VAR));
+ &errno H_ERRNO_VAR EXTRA_VARIABLES));
/* The status is NSS_STATUS_TRYAGAIN and errno is ERANGE the
provided buffer is too small. In this case we should give
@@ -238,8 +265,8 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
&& errno == ERANGE)
break;
- no_more = __nss_next (&nip, REENTRANT_NAME_STRING,
- &fct.ptr, status, 0);
+ no_more = __nss_next2 (&nip, REENTRANT_NAME_STRING,
+ REENTRANT2_NAME_STRING, &fct.ptr, status, 0);
}
#ifdef HANDLE_DIGITS_DOTS
@@ -274,10 +301,11 @@ done:
}
-#include <shlib-compat.h>
-#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1_2)
-#define OLD(name) OLD1 (name)
-#define OLD1(name) __old_##name
+#ifndef FUNCTION2_NAME
+# include <shlib-compat.h>
+# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1_2)
+# define OLD(name) OLD1 (name)
+# define OLD1(name) __old_##name
int
attribute_compat_text_section
@@ -293,19 +321,20 @@ OLD (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
return ret;
}
-#define do_symbol_version(real, name, version) \
+# define do_symbol_version(real, name, version) \
compat_symbol (libc, real, name, version)
do_symbol_version (OLD (REENTRANT_NAME), REENTRANT_NAME, GLIBC_2_0);
-#endif
+# endif
/* As INTERNAL (REENTRANT_NAME) may be hidden, we need an alias
in between so that the REENTRANT_NAME@@GLIBC_2.1.2 is not
hidden too. */
strong_alias (INTERNAL (REENTRANT_NAME), NEW (REENTRANT_NAME));
-#define do_default_symbol_version(real, name, version) \
+# define do_default_symbol_version(real, name, version) \
versioned_symbol (libc, real, name, version)
do_default_symbol_version (NEW (REENTRANT_NAME),
REENTRANT_NAME, GLIBC_2_1_2);
+#endif
static_link_warning (REENTRANT_NAME)