diff options
Diffstat (limited to 'nss/getXXbyYY_r.c')
-rw-r--r-- | nss/getXXbyYY_r.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/nss/getXXbyYY_r.c b/nss/getXXbyYY_r.c index 7cab825..6c547ea 100644 --- a/nss/getXXbyYY_r.c +++ b/nss/getXXbyYY_r.c @@ -26,7 +26,7 @@ # include <nscd/nscd_proto.h> #endif #ifdef NEED__RES -# include <resolv.h> +# include <resolv/resolv_context.h> #endif /*******************************************************************\ |* Here we assume several symbols to be defined: *| @@ -53,8 +53,7 @@ |* NEED_H_ERRNO - an extra parameter will be passed to point to *| |* the global `h_errno' variable. *| |* *| -|* NEED__RES - the global _res variable might be used so we *| -|* will have to initialize it if necessary *| +|* NEED__RES - obtain a struct resolv_context resolver context *| |* *| |* PREPROCESS - code run before anything else *| |* *| @@ -213,6 +212,18 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer, bool any_service = false; #endif +#ifdef NEED__RES + /* The HANDLE_DIGITS_DOTS case below already needs the resolver + configuration, so this has to happen early. */ + struct resolv_context *res_ctx = __resolv_context_get (); + if (res_ctx == NULL) + { + *h_errnop = NETDB_INTERNAL; + *result = NULL; + return errno; + } +#endif /* NEED__RES */ + #ifdef PREPROCESS PREPROCESS; #endif @@ -260,17 +271,6 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer, } else { -#ifdef NEED__RES - /* The resolver code will really be used so we have to - initialize it. */ - if (__res_maybe_init (&_res, 0) == -1) - { - *h_errnop = NETDB_INTERNAL; - *result = NULL; - return errno; - } -#endif /* need _res */ - void *tmp_ptr = fct.l; #ifdef PTR_MANGLE PTR_MANGLE (tmp_ptr); @@ -399,6 +399,12 @@ done: POSTPROCESS; #endif +#ifdef NEED__RES + /* This has to happen late because the POSTPROCESS stage above might + need the resolver context. */ + __resolv_context_put (res_ctx); +#endif /* NEED__RES */ + int res; if (status == NSS_STATUS_SUCCESS || status == NSS_STATUS_NOTFOUND) res = 0; |