mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-24 14:00:30 +00:00
iAdd __nscd_getai prototype.
This commit is contained in:
parent
40a8d825af
commit
62417d7ee8
@ -82,6 +82,7 @@ CFLAGS-xmalloc.c = -fpie
|
|||||||
CFLAGS-xstrdup.c = -fpie
|
CFLAGS-xstrdup.c = -fpie
|
||||||
CFLAGS-mem.c = -fpie
|
CFLAGS-mem.c = -fpie
|
||||||
CFLAGS-nscd_setup_thread.c = -fpie
|
CFLAGS-nscd_setup_thread.c = -fpie
|
||||||
|
CFLAGS-aicache.c = -fpie
|
||||||
|
|
||||||
$(objpfx)nscd: $(addprefix $(objpfx),$(nscd-modules:=.o))
|
$(objpfx)nscd: $(addprefix $(objpfx),$(nscd-modules:=.o))
|
||||||
$(LINK.o) -pie -Wl,-O1 \
|
$(LINK.o) -pie -Wl,-O1 \
|
||||||
|
@ -294,8 +294,4 @@ extern const struct datahead *__nscd_cache_search (request_type type,
|
|||||||
size_t keylen,
|
size_t keylen,
|
||||||
const struct mapped_database *mapped);
|
const struct mapped_database *mapped);
|
||||||
|
|
||||||
/* Look up in addrinfo cache. */
|
|
||||||
extern int __nscd_getai (const char *key, struct nscd_ai_result **result,
|
|
||||||
int *h_errnop);
|
|
||||||
|
|
||||||
#endif /* nscd.h */
|
#endif /* nscd.h */
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <not-cancel.h>
|
#include <not-cancel.h>
|
||||||
|
|
||||||
#include "nscd-client.h"
|
#include "nscd-client.h"
|
||||||
|
#include "nscd_proto.h"
|
||||||
|
|
||||||
|
|
||||||
/* Define in nscd_gethst_r.c. */
|
/* Define in nscd_gethst_r.c. */
|
||||||
|
@ -72,7 +72,7 @@ void
|
|||||||
__nscd_unmap (struct mapped_database *mapped)
|
__nscd_unmap (struct mapped_database *mapped)
|
||||||
{
|
{
|
||||||
assert (mapped->counter == 0);
|
assert (mapped->counter == 0);
|
||||||
munmap ((void *) mapped->head, mapped->mapsize);
|
__munmap ((void *) mapped->head, mapped->mapsize);
|
||||||
free (mapped);
|
free (mapped);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ get_mapping (request_type type, const char *key,
|
|||||||
if (newp == NULL)
|
if (newp == NULL)
|
||||||
{
|
{
|
||||||
/* Ugh, after all we went through the memory allocation failed. */
|
/* Ugh, after all we went through the memory allocation failed. */
|
||||||
munmap (result, size);
|
__munmap (result, size);
|
||||||
goto out_close;
|
goto out_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,9 @@
|
|||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
|
||||||
|
/* Interval in which we transfer retry to contact the NSCD. */
|
||||||
|
#define NSS_NSCD_RETRY 100
|
||||||
|
|
||||||
/* Variables for communication between NSCD handler functions and NSS. */
|
/* Variables for communication between NSCD handler functions and NSS. */
|
||||||
extern int __nss_not_use_nscd_passwd attribute_hidden;
|
extern int __nss_not_use_nscd_passwd attribute_hidden;
|
||||||
extern int __nss_not_use_nscd_group attribute_hidden;
|
extern int __nss_not_use_nscd_group attribute_hidden;
|
||||||
@ -53,5 +56,7 @@ extern int __nscd_gethostbyaddr_r (const void *addr, socklen_t len, int type,
|
|||||||
struct hostent *resultbuf,
|
struct hostent *resultbuf,
|
||||||
char *buffer, size_t buflen,
|
char *buffer, size_t buflen,
|
||||||
struct hostent **result, int *h_errnop);
|
struct hostent **result, int *h_errnop);
|
||||||
|
extern int __nscd_getai (const char *key, struct nscd_ai_result **result,
|
||||||
|
int *h_errnop);
|
||||||
|
|
||||||
#endif /* _NSCD_PROTO_H */
|
#endif /* _NSCD_PROTO_H */
|
||||||
|
@ -114,9 +114,6 @@ extern int DB_LOOKUP_FCT (service_user **nip, const char *name, void **fctp)
|
|||||||
internal_function;
|
internal_function;
|
||||||
libc_hidden_proto (DB_LOOKUP_FCT)
|
libc_hidden_proto (DB_LOOKUP_FCT)
|
||||||
|
|
||||||
/* Interval in which we transfer retry to contact the NSCD. */
|
|
||||||
#define NSS_NSCD_RETRY 100
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
|
INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
|
||||||
|
@ -55,6 +55,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <nsswitch.h>
|
#include <nsswitch.h>
|
||||||
#include <not-cancel.h>
|
#include <not-cancel.h>
|
||||||
#include <nscd/nscd-client.h>
|
#include <nscd/nscd-client.h>
|
||||||
|
#include <nscd/nscd_proto.h>
|
||||||
|
|
||||||
#ifdef HAVE_LIBIDN
|
#ifdef HAVE_LIBIDN
|
||||||
extern int __idna_to_ascii_lz (const char *input, char **output, int flags);
|
extern int __idna_to_ascii_lz (const char *input, char **output, int flags);
|
||||||
@ -672,69 +673,76 @@ gaih_inet (const char *name, const struct gaih_service *service,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_NSCD
|
#ifdef USE_NSCD
|
||||||
/* Try to use nscd. */
|
if (__nss_not_use_nscd_hosts > 0
|
||||||
struct nscd_ai_result *air = NULL;
|
&& ++__nss_not_use_nscd_hosts > NSS_NSCD_RETRY)
|
||||||
int herrno;
|
__nss_not_use_nscd_hosts = 0;
|
||||||
int err = __nscd_getai (name, &air, &herrno);
|
|
||||||
if (air != NULL)
|
|
||||||
{
|
|
||||||
/* Transform into gaih_addrtuple list. */
|
|
||||||
bool added_canon = (req->ai_flags & AI_CANONNAME) == 0;
|
|
||||||
char *addrs = air->addrs;
|
|
||||||
|
|
||||||
for (int i = 0; i < air->naddrs; ++i)
|
if (!__nss_not_use_nscd_hosts)
|
||||||
|
{
|
||||||
|
/* Try to use nscd. */
|
||||||
|
struct nscd_ai_result *air = NULL;
|
||||||
|
int herrno;
|
||||||
|
int err = __nscd_getai (name, &air, &herrno);
|
||||||
|
if (air != NULL)
|
||||||
{
|
{
|
||||||
socklen_t size = (air->family[i] == AF_INET
|
/* Transform into gaih_addrtuple list. */
|
||||||
? INADDRSZ : IN6ADDRSZ);
|
bool added_canon = (req->ai_flags & AI_CANONNAME) == 0;
|
||||||
if (*pat == NULL)
|
char *addrs = air->addrs;
|
||||||
{
|
|
||||||
*pat = __alloca (sizeof (struct gaih_addrtuple));
|
|
||||||
(*pat)->scopeid = 0;
|
|
||||||
}
|
|
||||||
uint32_t *pataddr = (*pat)->addr;
|
|
||||||
(*pat)->next = NULL;
|
|
||||||
if (added_canon || air->canon == NULL)
|
|
||||||
(*pat)->name = NULL;
|
|
||||||
else
|
|
||||||
canon = (*pat)->name = strdupa (air->canon);
|
|
||||||
|
|
||||||
if (air->family[i] == AF_INET
|
for (int i = 0; i < air->naddrs; ++i)
|
||||||
&& req->ai_family == AF_INET6
|
|
||||||
&& (req->ai_flags & AI_V4MAPPED))
|
|
||||||
{
|
{
|
||||||
(*pat)->family = AF_INET6;
|
socklen_t size = (air->family[i] == AF_INET
|
||||||
pataddr[3] = *(uint32_t *) addrs;
|
? INADDRSZ : IN6ADDRSZ);
|
||||||
pataddr[2] = htonl (0xffff);
|
if (*pat == NULL)
|
||||||
pataddr[1] = 0;
|
{
|
||||||
pataddr[0] = 0;
|
*pat = __alloca (sizeof (struct gaih_addrtuple));
|
||||||
pat = &((*pat)->next);
|
(*pat)->scopeid = 0;
|
||||||
added_canon = true;
|
}
|
||||||
|
uint32_t *pataddr = (*pat)->addr;
|
||||||
|
(*pat)->next = NULL;
|
||||||
|
if (added_canon || air->canon == NULL)
|
||||||
|
(*pat)->name = NULL;
|
||||||
|
else
|
||||||
|
canon = (*pat)->name = strdupa (air->canon);
|
||||||
|
|
||||||
|
if (air->family[i] == AF_INET
|
||||||
|
&& req->ai_family == AF_INET6
|
||||||
|
&& (req->ai_flags & AI_V4MAPPED))
|
||||||
|
{
|
||||||
|
(*pat)->family = AF_INET6;
|
||||||
|
pataddr[3] = *(uint32_t *) addrs;
|
||||||
|
pataddr[2] = htonl (0xffff);
|
||||||
|
pataddr[1] = 0;
|
||||||
|
pataddr[0] = 0;
|
||||||
|
pat = &((*pat)->next);
|
||||||
|
added_canon = true;
|
||||||
|
}
|
||||||
|
else if (req->ai_family == AF_UNSPEC
|
||||||
|
|| air->family[i] == req->ai_family)
|
||||||
|
{
|
||||||
|
(*pat)->family = air->family[i];
|
||||||
|
memcpy (pataddr, addrs, size);
|
||||||
|
pat = &((*pat)->next);
|
||||||
|
added_canon = true;
|
||||||
|
if (air->family[i] == AF_INET6)
|
||||||
|
got_ipv6 = true;
|
||||||
|
}
|
||||||
|
addrs += size;
|
||||||
}
|
}
|
||||||
else if (req->ai_family == AF_UNSPEC
|
|
||||||
|| air->family[i] == req->ai_family)
|
if (at->family == AF_UNSPEC)
|
||||||
{
|
return (GAIH_OKIFUNSPEC | -EAI_NONAME);
|
||||||
(*pat)->family = air->family[i];
|
|
||||||
memcpy (pataddr, addrs, size);
|
goto process_list;
|
||||||
pat = &((*pat)->next);
|
}
|
||||||
added_canon = true;
|
else if (err != 0 && __nss_not_use_nscd_hosts == 0)
|
||||||
if (air->family[i] == AF_INET6)
|
{
|
||||||
got_ipv6 = true;
|
if (herrno == NETDB_INTERNAL && errno == ENOMEM)
|
||||||
}
|
return -EAI_MEMORY;
|
||||||
addrs += size;
|
if (herrno == TRY_AGAIN)
|
||||||
|
return -EAI_AGAIN;
|
||||||
|
return -EAI_SYSTEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (at->family == AF_UNSPEC)
|
|
||||||
return (GAIH_OKIFUNSPEC | -EAI_NONAME);
|
|
||||||
|
|
||||||
goto process_list;
|
|
||||||
}
|
|
||||||
else if (err != 0)
|
|
||||||
{
|
|
||||||
if (herrno == NETDB_INTERNAL && errno == ENOMEM)
|
|
||||||
return -EAI_MEMORY;
|
|
||||||
if (herrno == TRY_AGAIN)
|
|
||||||
return -EAI_AGAIN;
|
|
||||||
return -EAI_SYSTEM;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user