mirror of
git://sourceware.org/git/glibc.git
synced 2025-01-18 12:16:13 +08:00
Update.
1999-08-29 Thorsten Kukuk <kukuk@suse.de> * nis/Versions: Add _nss_*_getipnodebyname_r. * nis/nss_nis/nis-hosts.c: Add _nss_nis_getipnodebyname_r. * nis/nss_nisplus/nisplus-hosts.c: Add _nss_nisplus_getipnodebyname_r. * nss/Versions: Add _nss_files_getipnodebyname_r.
This commit is contained in:
parent
74bced63c5
commit
1e275b9e9b
@ -1,3 +1,10 @@
|
||||
1999-08-29 Thorsten Kukuk <kukuk@suse.de>
|
||||
|
||||
* nis/Versions: Add _nss_*_getipnodebyname_r.
|
||||
* nis/nss_nis/nis-hosts.c: Add _nss_nis_getipnodebyname_r.
|
||||
* nis/nss_nisplus/nisplus-hosts.c: Add _nss_nisplus_getipnodebyname_r.
|
||||
* nss/Versions: Add _nss_files_getipnodebyname_r.
|
||||
|
||||
1999-08-28 H.J. Lu <hjl@gnu.org>
|
||||
|
||||
* nscd/nscd_getgr_r.c (nscd_getgr_r): Don't count the alloca'ed
|
||||
|
@ -91,6 +91,9 @@ libnss_nis {
|
||||
_nss_nis_setnetgrent; _nss_nis_setprotoent; _nss_nis_setpwent;
|
||||
_nss_nis_setrpcent; _nss_nis_setservent; _nss_nis_setspent;
|
||||
}
|
||||
GLIBC_2.2 {
|
||||
_nss_nis_getipnodebyname_r;
|
||||
}
|
||||
}
|
||||
|
||||
libnss_nisplus {
|
||||
@ -122,4 +125,7 @@ libnss_nisplus {
|
||||
_nss_nisplus_setpwent; _nss_nisplus_setrpcent; _nss_nisplus_setservent;
|
||||
_nss_nisplus_setspent;
|
||||
}
|
||||
GLIBC_2.2 {
|
||||
_nss_nisplus_getipnodebyname_r;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
|
||||
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
@ -37,6 +37,9 @@
|
||||
#define DATABASE "hosts"
|
||||
#define NEED_H_ERRNO
|
||||
|
||||
#define EXTRA_ARGS , af, flags
|
||||
#define EXTRA_ARGS_DECL , int af, int flags
|
||||
|
||||
#define ENTDATA hostent_data
|
||||
struct hostent_data
|
||||
{
|
||||
@ -55,15 +58,9 @@ LINE_PARSER
|
||||
STRING_FIELD (addr, isspace, 1);
|
||||
|
||||
/* Parse address. */
|
||||
if (inet_pton (AF_INET6, addr, entdata->host_addr) > 0)
|
||||
if (af == AF_INET && inet_pton (AF_INET, addr, entdata->host_addr) > 0)
|
||||
{
|
||||
result->h_addrtype = AF_INET6;
|
||||
result->h_length = IN6ADDRSZ;
|
||||
}
|
||||
else
|
||||
if (inet_pton (AF_INET, addr, entdata->host_addr) > 0)
|
||||
{
|
||||
if (_res.options & RES_USE_INET6)
|
||||
if (flags & AI_V4MAPPED)
|
||||
{
|
||||
map_v4v6_address ((char *) entdata->host_addr,
|
||||
(char *) entdata->host_addr);
|
||||
@ -76,6 +73,12 @@ LINE_PARSER
|
||||
result->h_length = INADDRSZ;
|
||||
}
|
||||
}
|
||||
else if (af == AF_INET6
|
||||
&& inet_pton (AF_INET6, addr, entdata->host_addr) > 0)
|
||||
{
|
||||
result->h_addrtype = AF_INET6;
|
||||
result->h_length = IN6ADDRSZ;
|
||||
}
|
||||
else
|
||||
/* Illegal address: ignore line. */
|
||||
return 0;
|
||||
@ -86,8 +89,8 @@ LINE_PARSER
|
||||
result->h_addr_list = entdata->h_addr_ptrs;
|
||||
|
||||
STRING_FIELD (result->h_name, isspace, 1);
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
__libc_lock_define_initialized (static, lock)
|
||||
|
||||
@ -131,9 +134,11 @@ _nss_nis_endhostent (void)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* The calling function always need to get a lock first. */
|
||||
static enum nss_status
|
||||
internal_nis_gethostent_r (struct hostent *host, char *buffer,
|
||||
size_t buflen, int *errnop, int *h_errnop)
|
||||
size_t buflen, int *errnop, int *h_errnop,
|
||||
int af, int flags)
|
||||
{
|
||||
char *domain;
|
||||
char *result;
|
||||
@ -200,7 +205,7 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer,
|
||||
++p;
|
||||
free (result);
|
||||
|
||||
parse_res = parse_line (p, host, data, buflen, errnop);
|
||||
parse_res = parse_line (p, host, data, buflen, errnop, af, flags);
|
||||
if (parse_res == -1)
|
||||
{
|
||||
free (outkey);
|
||||
@ -219,25 +224,27 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer,
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
enum nss_status
|
||||
_nss_nis_gethostent_r (struct hostent *host, char *buffer, size_t buflen,
|
||||
int *errnop, int *h_errnop)
|
||||
{
|
||||
int status;
|
||||
enum nss_status status;
|
||||
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
status = internal_nis_gethostent_r (host, buffer, buflen, errnop, h_errnop);
|
||||
status = internal_nis_gethostent_r (host, buffer, buflen, errnop, h_errnop,
|
||||
((_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET),
|
||||
((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0 ));
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host,
|
||||
static enum nss_status
|
||||
internal_gethostbyname2_r (const char *name, int af, struct hostent *host,
|
||||
char *buffer, size_t buflen, int *errnop,
|
||||
int *h_errnop)
|
||||
int *h_errnop, int flags)
|
||||
{
|
||||
enum nss_status retval;
|
||||
char *domain, *result, *p;
|
||||
@ -302,7 +309,7 @@ _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host,
|
||||
++p;
|
||||
free (result);
|
||||
|
||||
parse_res = parse_line (p, host, data, buflen, errnop);
|
||||
parse_res = parse_line (p, host, data, buflen, errnop, af, flags);
|
||||
|
||||
if (parse_res < 1 || host->h_addrtype != af)
|
||||
{
|
||||
@ -322,6 +329,16 @@ _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host,
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host,
|
||||
char *buffer, size_t buflen, int *errnop,
|
||||
int *h_errnop)
|
||||
{
|
||||
return internal_gethostbyname2_r (name, af, host, buffer, buflen, errnop,
|
||||
h_errnop,
|
||||
((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0));
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nis_gethostbyname_r (const char *name, struct hostent *host, char *buffer,
|
||||
size_t buflen, int *errnop, int *h_errnop)
|
||||
@ -330,18 +347,18 @@ _nss_nis_gethostbyname_r (const char *name, struct hostent *host, char *buffer,
|
||||
{
|
||||
enum nss_status status;
|
||||
|
||||
status = _nss_nis_gethostbyname2_r (name, AF_INET6, host, buffer, buflen,
|
||||
errnop, h_errnop);
|
||||
status = internal_gethostbyname2_r (name, AF_INET6, host, buffer, buflen,
|
||||
errnop, h_errnop, AI_V4MAPPED);
|
||||
if (status == NSS_STATUS_SUCCESS)
|
||||
return status;
|
||||
}
|
||||
|
||||
return _nss_nis_gethostbyname2_r (name, AF_INET, host, buffer, buflen,
|
||||
errnop, h_errnop);
|
||||
return internal_gethostbyname2_r (name, AF_INET, host, buffer, buflen,
|
||||
errnop, h_errnop, 0);
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nis_gethostbyaddr_r (char *addr, size_t addrlen, int type,
|
||||
_nss_nis_gethostbyaddr_r (char *addr, size_t addrlen, int af,
|
||||
struct hostent *host, char *buffer, size_t buflen,
|
||||
int *errnop, int *h_errnop)
|
||||
{
|
||||
@ -393,7 +410,8 @@ _nss_nis_gethostbyaddr_r (char *addr, size_t addrlen, int type,
|
||||
++p;
|
||||
free (result);
|
||||
|
||||
parse_res = parse_line (p, host, data, buflen, errnop);
|
||||
parse_res = parse_line (p, host, data, buflen, errnop, af,
|
||||
((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0));
|
||||
if (parse_res < 1)
|
||||
{
|
||||
if (parse_res == -1)
|
||||
@ -411,3 +429,12 @@ _nss_nis_gethostbyaddr_r (char *addr, size_t addrlen, int type,
|
||||
*h_errnop = NETDB_SUCCESS;
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nis_getipnodebyname_r (const char *name, int af, int flags,
|
||||
struct hostent *result, char *buffer,
|
||||
size_t buflen, int *errnop, int *herrnop)
|
||||
{
|
||||
return internal_gethostbyname2_r (name, af, result, buffer, buflen,
|
||||
errnop, herrnop, flags);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
|
||||
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
@ -46,7 +46,8 @@ static u_long tablename_len = 0;
|
||||
|
||||
static int
|
||||
_nss_nisplus_parse_hostent (nis_result *result, int af, struct hostent *host,
|
||||
char *buffer, size_t buflen, int *errnop)
|
||||
char *buffer, size_t buflen, int *errnop,
|
||||
int flags)
|
||||
{
|
||||
unsigned int i;
|
||||
char *first_unused = buffer;
|
||||
@ -71,16 +72,11 @@ _nss_nisplus_parse_hostent (nis_result *result, int af, struct hostent *host,
|
||||
}
|
||||
|
||||
data = first_unused;
|
||||
if (inet_pton (af, NISENTRYVAL (0, 2, result), data) < 1)
|
||||
/* Illegal address: ignore line. */
|
||||
return 0;
|
||||
|
||||
host->h_addrtype = af;
|
||||
if (af == AF_INET6)
|
||||
host->h_length = IN6ADDRSZ;
|
||||
else
|
||||
/* Parse address. */
|
||||
if (af == AF_INET && inet_pton (af, NISENTRYVAL (0, 2, result), data) > 0)
|
||||
{
|
||||
if (_res.options & RES_USE_INET6)
|
||||
if (flags & AI_V4MAPPED)
|
||||
{
|
||||
map_v4v6_address (data, data);
|
||||
host->h_addrtype = AF_INET6;
|
||||
@ -92,6 +88,16 @@ _nss_nisplus_parse_hostent (nis_result *result, int af, struct hostent *host,
|
||||
host->h_length = INADDRSZ;
|
||||
}
|
||||
}
|
||||
else if (af == AF_INET6
|
||||
&& inet_pton (AF_INET6, NISENTRYVAL (0, 2, result), data) > 0)
|
||||
{
|
||||
host->h_addrtype = AF_INET6;
|
||||
host->h_length = IN6ADDRSZ;
|
||||
}
|
||||
else
|
||||
/* Illegal address: ignore line. */
|
||||
return 0;
|
||||
|
||||
first_unused+=host->h_length;
|
||||
room_left-=host->h_length;
|
||||
|
||||
@ -281,11 +287,13 @@ internal_nisplus_gethostent_r (struct hostent *host, char *buffer,
|
||||
}
|
||||
}
|
||||
|
||||
if (_res.options & RES_USE_INET6)
|
||||
parse_res = _nss_nisplus_parse_hostent (result, AF_INET6, host, buffer,
|
||||
buflen, errnop);
|
||||
if (parse_res < 1 && *errnop != ERANGE)
|
||||
parse_res = _nss_nisplus_parse_hostent (result, AF_INET, host,
|
||||
buffer, buflen, errnop);
|
||||
buflen, errnop, AI_V4MAPPED);
|
||||
else
|
||||
parse_res = _nss_nisplus_parse_hostent (result, AF_INET, host, buffer,
|
||||
buflen, errnop, 0);
|
||||
|
||||
if (parse_res == -1)
|
||||
{
|
||||
nis_freeresult (result);
|
||||
@ -318,10 +326,10 @@ _nss_nisplus_gethostent_r (struct hostent *result, char *buffer,
|
||||
return status;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_gethostbyname2_r (const char *name, int af, struct hostent *host,
|
||||
static enum nss_status
|
||||
internal_gethostbyname2_r (const char *name, int af, struct hostent *host,
|
||||
char *buffer, size_t buflen, int *errnop,
|
||||
int *herrnop)
|
||||
int *herrnop, int flags)
|
||||
{
|
||||
int parse_res, retval;
|
||||
|
||||
@ -380,7 +388,7 @@ _nss_nisplus_gethostbyname2_r (const char *name, int af, struct hostent *host,
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_hostent (result, af, host, buffer,
|
||||
buflen, errnop);
|
||||
buflen, errnop, flags);
|
||||
|
||||
nis_freeresult (result);
|
||||
|
||||
@ -398,6 +406,25 @@ _nss_nisplus_gethostbyname2_r (const char *name, int af, struct hostent *host,
|
||||
}
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_gethostbyname2_r (const char *name, int af, struct hostent *host,
|
||||
char *buffer, size_t buflen, int *errnop,
|
||||
int *herrnop)
|
||||
{
|
||||
return internal_gethostbyname2_r (name, af, host, buffer, buflen, errnop,
|
||||
herrnop,
|
||||
((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0));
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getipnodebyname_r (const char *name, int af, int flags,
|
||||
struct hostent *result, char *buffer,
|
||||
size_t buflen, int *errnop, int *herrnop)
|
||||
{
|
||||
return internal_gethostbyname2_r (name, af, result, buffer, buflen,
|
||||
errnop, herrnop, flags);
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_gethostbyname_r (const char *name, struct hostent *host,
|
||||
char *buffer, size_t buflen, int *errnop,
|
||||
@ -407,18 +434,19 @@ _nss_nisplus_gethostbyname_r (const char *name, struct hostent *host,
|
||||
{
|
||||
enum nss_status status;
|
||||
|
||||
status = _nss_nisplus_gethostbyname2_r (name, AF_INET6, host, buffer,
|
||||
buflen, errnop, h_errnop);
|
||||
status = internal_gethostbyname2_r (name, AF_INET6, host, buffer,
|
||||
buflen, errnop, h_errnop,
|
||||
AI_V4MAPPED);
|
||||
if (status == NSS_STATUS_SUCCESS)
|
||||
return status;
|
||||
}
|
||||
|
||||
return _nss_nisplus_gethostbyname2_r (name, AF_INET, host, buffer,
|
||||
buflen, errnop, h_errnop);
|
||||
return internal_gethostbyname2_r (name, AF_INET, host, buffer,
|
||||
buflen, errnop, h_errnop, 0);
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_gethostbyaddr_r (const char *addr, size_t addrlen, int type,
|
||||
_nss_nisplus_gethostbyaddr_r (const char *addr, size_t addrlen, int af,
|
||||
struct hostent *host, char *buffer,
|
||||
size_t buflen, int *errnop, int *herrnop)
|
||||
{
|
||||
@ -454,8 +482,9 @@ _nss_nisplus_gethostbyaddr_r (const char *addr, size_t addrlen, int type,
|
||||
return retval;
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_hostent (result, type, host,
|
||||
buffer, buflen, errnop);
|
||||
parse_res = _nss_nisplus_parse_hostent (result, af, host,
|
||||
buffer, buflen, errnop,
|
||||
((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0));
|
||||
nis_freeresult (result);
|
||||
|
||||
if (parse_res > 0)
|
||||
|
@ -102,4 +102,7 @@ libnss_files {
|
||||
_nss_files_getpublickey;
|
||||
_nss_files_getsecretkey;
|
||||
}
|
||||
GLIBC_2.2 {
|
||||
_nss_files_getipnodebyname_r;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <error.h>
|
||||
#include <sys/types.h>
|
||||
#include <regex.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
|
@ -49,6 +49,8 @@ static const struct test_times tests[] =
|
||||
{ NULL, 0, 0 }
|
||||
};
|
||||
|
||||
/* This string will be used for `putenv' calls. */
|
||||
char envstring[100];
|
||||
|
||||
void
|
||||
print_tzvars (void)
|
||||
@ -123,7 +125,8 @@ main (int argc, char ** argv)
|
||||
{
|
||||
struct tm tmBuf = {0, 0, 0, 10, 3, 98, 0, 0, -1};
|
||||
char buf[200];
|
||||
putenv ("TZ=Europe/London");
|
||||
strcpy (envstring, "TZ=Europe/London");
|
||||
putenv (envstring);
|
||||
t = mktime (&tmBuf);
|
||||
snprintf (buf, sizeof (buf), "TZ=%s %ld %d %d %d %d %d %d %d %d %d",
|
||||
getenv ("TZ"), t,
|
||||
@ -145,7 +148,8 @@ main (int argc, char ** argv)
|
||||
{
|
||||
struct tm tmBuf = {0, 0, 0, 10, 3, 98, 0, 0, -1};
|
||||
char buf[200];
|
||||
putenv ("TZ=GMT");
|
||||
strcpy (envstring, "TZ=GMT");
|
||||
/* No putenv call needed! */
|
||||
t = mktime (&tmBuf);
|
||||
snprintf (buf, sizeof (buf), "TZ=%s %ld %d %d %d %d %d %d %d %d %d",
|
||||
getenv ("TZ"), t,
|
||||
|
Loading…
Reference in New Issue
Block a user