diff options
author | Ulrich Drepper <drepper@redhat.com> | 2007-10-30 00:48:09 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2007-10-30 00:48:09 +0000 |
commit | 384ca551743318bd9c9e24a496d6397f2e3f2a49 (patch) | |
tree | 86803bb391775670bd8dece020a91ba870a202d4 /nss | |
parent | 53bab260f5a80da3c6900d03ae92d2f3ef28bacb (diff) | |
download | glibc-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')
-rw-r--r-- | nss/Versions | 5 | ||||
-rw-r--r-- | nss/XXX-lookup.c | 23 | ||||
-rw-r--r-- | nss/getXXbyYY_r.c | 63 | ||||
-rw-r--r-- | nss/getXXent_r.c | 7 | ||||
-rw-r--r-- | nss/getnssent_r.c | 18 | ||||
-rw-r--r-- | nss/nsswitch.c | 27 | ||||
-rw-r--r-- | nss/nsswitch.h | 11 | ||||
-rw-r--r-- | nss/service-lookup.c | 3 |
8 files changed, 112 insertions, 45 deletions
diff --git a/nss/Versions b/nss/Versions index 365f9e2..8f2f0fb 100644 --- a/nss/Versions +++ b/nss/Versions @@ -9,7 +9,10 @@ libc { } GLIBC_PRIVATE { _nss_files_parse_grent; _nss_files_parse_pwent; _nss_files_parse_spent; - __nss_disable_nscd; __nss_lookup_function; __nss_services_lookup; + __nss_disable_nscd; __nss_lookup_function; + + __nss_passwd_lookup2; __nss_group_lookup2; __nss_hosts_lookup2; + __nss_services_lookup2; __nss_next2; } } diff --git a/nss/XXX-lookup.c b/nss/XXX-lookup.c index da0e6f4..f88d69e 100644 --- a/nss/XXX-lookup.c +++ b/nss/XXX-lookup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1999, 2000, 2002, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -34,7 +34,8 @@ |* *| \*******************************************************************/ -#define DB_LOOKUP_FCT CONCAT3_1 (__nss_, DATABASE_NAME, _lookup) +#define DB_LOOKUP_FCT CONCAT3_1 (__nss_, DATABASE_NAME, _lookup2) +#define DB_COMPAT_FCT CONCAT3_1 (__nss_, DATABASE_NAME, _lookup) #define CONCAT3_1(Pre, Name, Post) CONCAT3_2 (Pre, Name, Post) #define CONCAT3_2(Pre, Name, Post) Pre##Name##Post @@ -56,12 +57,14 @@ service_user *DATABASE_NAME_SYMBOL attribute_hidden; extern int DB_LOOKUP_FCT (service_user **ni, const char *fct_name, - void **fctp) internal_function; + const char *fct2_name, void **fctp) + internal_function; libc_hidden_proto (DB_LOOKUP_FCT) int internal_function -DB_LOOKUP_FCT (service_user **ni, const char *fct_name, void **fctp) +DB_LOOKUP_FCT (service_user **ni, const char *fct_name, const char *fct2_name, + void **fctp) { if (DATABASE_NAME_SYMBOL == NULL && __nss_database_lookup (DATABASE_NAME_STRING, ALTERNATE_NAME_STRING, @@ -70,6 +73,16 @@ DB_LOOKUP_FCT (service_user **ni, const char *fct_name, void **fctp) *ni = DATABASE_NAME_SYMBOL; - return __nss_lookup (ni, fct_name, fctp); + return __nss_lookup (ni, fct_name, fct2_name, fctp); } libc_hidden_def (DB_LOOKUP_FCT) + + +#ifndef NO_COMPAT +int +internal_function attribute_compat_text_section +DB_COMPAT_FCT (service_user **ni, const char *fct_name, void **fctp) +{ + return DB_LOOKUP_FCT (ni, fct_name, NULL, fctp); +} +#endif 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) diff --git a/nss/getXXent_r.c b/nss/getXXent_r.c index db4abaf..7a881c0 100644 --- a/nss/getXXent_r.c +++ b/nss/getXXent_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996,97,98,99,2000,2002,2004 Free Software Foundation, Inc. +/* Copyright (C) 1996-2000,2002,2004,2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -64,7 +64,7 @@ #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 @@ -113,7 +113,8 @@ 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, 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) diff --git a/nss/getnssent_r.c b/nss/getnssent_r.c index a0cfa72..f50667a 100644 --- a/nss/getnssent_r.c +++ b/nss/getnssent_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2002, 2004, 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,7 +30,7 @@ setup (const char *func_name, db_lookup_function lookup_fct, int no_more; if (*startp == NULL) { - no_more = lookup_fct (nip, func_name, fctp); + no_more = lookup_fct (nip, func_name, NULL, fctp); *startp = no_more ? (service_user *) -1l : *nip; } else if (*startp == (service_user *) -1l) @@ -42,7 +42,7 @@ setup (const char *func_name, db_lookup_function lookup_fct, /* Reset to the beginning of the service list. */ *nip = *startp; /* Look up the first function. */ - no_more = __nss_lookup (nip, func_name, fctp); + no_more = __nss_lookup (nip, func_name, NULL, fctp); } return no_more; } @@ -80,8 +80,7 @@ __nss_setent (const char *func_name, db_lookup_function lookup_fct, else status = DL_CALL_FCT (fct.f, (0)); - no_more = __nss_next (nip, func_name, &fct.ptr, - status, 0); + no_more = __nss_next2 (nip, func_name, NULL, &fct.ptr, status, 0); if (is_last_nip) *last_nip = *nip; } @@ -120,7 +119,7 @@ __nss_endent (const char *func_name, db_lookup_function lookup_fct, /* We have processed all services which were used. */ break; - no_more = __nss_next (nip, func_name, &fct.ptr, 0, 1); + no_more = __nss_next2 (nip, func_name, NULL, &fct.ptr, 0, 1); } *last_nip = *nip = NULL; } @@ -177,8 +176,8 @@ __nss_getent_r (const char *getent_func_name, do { - no_more = __nss_next (nip, getent_func_name, &fct.ptr, - status, 0); + no_more = __nss_next2 (nip, getent_func_name, NULL, &fct.ptr, + status, 0); if (is_last_nip) *last_nip = *nip; @@ -192,8 +191,7 @@ __nss_getent_r (const char *getent_func_name, void *ptr; } sfct; - no_more = __nss_lookup (nip, setent_func_name, - &sfct.ptr); + no_more = __nss_lookup (nip, setent_func_name, NULL, &sfct.ptr); if (! no_more) { diff --git a/nss/nsswitch.c b/nss/nsswitch.c index 46965fd8f..28aa1b4 100644 --- a/nss/nsswitch.c +++ b/nss/nsswitch.c @@ -145,9 +145,12 @@ libc_hidden_def (__nss_database_lookup) 0 == function found 1 == finished */ int -__nss_lookup (service_user **ni, const char *fct_name, void **fctp) +__nss_lookup (service_user **ni, const char *fct_name, const char *fct2_name, + void **fctp) { *fctp = __nss_lookup_function (*ni, fct_name); + if (*fctp == NULL && fct2_name != NULL) + *fctp = __nss_lookup_function (*ni, fct_name); while (*fctp == NULL && nss_next_action (*ni, NSS_STATUS_UNAVAIL) == NSS_ACTION_CONTINUE @@ -156,6 +159,8 @@ __nss_lookup (service_user **ni, const char *fct_name, void **fctp) *ni = (*ni)->next; *fctp = __nss_lookup_function (*ni, fct_name); + if (*fctp == NULL && fct2_name != NULL) + *fctp = __nss_lookup_function (*ni, fct_name); } return *fctp != NULL ? 0 : (*ni)->next == NULL ? 1 : -1; @@ -166,8 +171,8 @@ __nss_lookup (service_user **ni, const char *fct_name, void **fctp) 0 == adjusted for next function 1 == finished */ int -__nss_next (service_user **ni, const char *fct_name, void **fctp, int status, - int all_values) +__nss_next2 (service_user **ni, const char *fct_name, const char *fct2_name, + void **fctp, int status, int all_values) { if (all_values) { @@ -180,7 +185,8 @@ __nss_next (service_user **ni, const char *fct_name, void **fctp, int status, else { /* This is really only for debugging. */ - if (NSS_STATUS_TRYAGAIN > status || status > NSS_STATUS_RETURN) + if (__builtin_expect (NSS_STATUS_TRYAGAIN > status + || status > NSS_STATUS_RETURN, 0)) __libc_fatal ("illegal status in __nss_next"); if (nss_next_action (*ni, status) == NSS_ACTION_RETURN) @@ -195,6 +201,8 @@ __nss_next (service_user **ni, const char *fct_name, void **fctp, int status, *ni = (*ni)->next; *fctp = __nss_lookup_function (*ni, fct_name); + if (*fctp == NULL && fct2_name != NULL) + *fctp = __nss_lookup_function (*ni, fct2_name); } while (*fctp == NULL && nss_next_action (*ni, NSS_STATUS_UNAVAIL) == NSS_ACTION_CONTINUE @@ -202,7 +210,16 @@ __nss_next (service_user **ni, const char *fct_name, void **fctp, int status, return *fctp != NULL ? 0 : -1; } -libc_hidden_def (__nss_next) +libc_hidden_def (__nss_next2) + + +int +attribute_compat_text_section +__nss_next (service_user **ni, const char *fct_name, void **fctp, int status, + int all_values) +{ + return __nss_next2 (ni, fct_name, NULL, fctp, status, all_values); +} int diff --git a/nss/nsswitch.h b/nss/nsswitch.h index d222e0d..b80edef 100644 --- a/nss/nsswitch.h +++ b/nss/nsswitch.h @@ -110,7 +110,8 @@ libc_hidden_proto (__nss_database_lookup) /* Put first function with name FCT_NAME for SERVICE in FCTP. The position is remembered in NI. The function returns a value < 0 if an error occurred or no such function exists. */ -extern int __nss_lookup (service_user **ni, const char *fct_name, void **fctp); +extern int __nss_lookup (service_user **ni, const char *fct_name, + const char *fct2_name, void **fctp) attribute_hidden; /* Determine the next step in the lookup process according to the result STATUS of the call to the last function returned by @@ -125,9 +126,12 @@ extern int __nss_lookup (service_user **ni, const char *fct_name, void **fctp); services. In other words, only if all four lookup results have the action RETURN associated the lookup process stops before the natural end. */ +extern int __nss_next2 (service_user **ni, const char *fct_name, + const char *fct2_name, void **fctp, int status, + int all_values) attribute_hidden; +libc_hidden_proto (__nss_next2) extern int __nss_next (service_user **ni, const char *fct_name, void **fctp, int status, int all_values); -libc_hidden_proto (__nss_next) /* Search for the service described in NI for a function named FCT_NAME and return a pointer to this function if successful. */ @@ -139,7 +143,8 @@ libc_hidden_proto (__nss_lookup_function) extern void __nss_disable_nscd (void); -typedef int (*db_lookup_function) (service_user **, const char *, void **) +typedef int (*db_lookup_function) (service_user **, const char *, const char *, + void **) internal_function; typedef enum nss_status (*setent_function) (int); typedef enum nss_status (*endent_function) (void); diff --git a/nss/service-lookup.c b/nss/service-lookup.c index 67d401e..f356185 100644 --- a/nss/service-lookup.c +++ b/nss/service-lookup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -18,5 +18,6 @@ 02111-1307 USA. */ #define DATABASE_NAME services +#define NO_COMPAT #include "XXX-lookup.c" |