aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--nis/Versions6
-rw-r--r--nis/nss_nis/nis-hosts.c101
-rw-r--r--nis/nss_nisplus/nisplus-hosts.c83
-rw-r--r--nss/Versions3
-rw-r--r--posix/regexbug1.c1
-rw-r--r--timezone/tst-timezone.c8
7 files changed, 144 insertions, 67 deletions
diff --git a/ChangeLog b/ChangeLog
index 6cdfa8e..80286e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,15 @@
+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
memory for buffer.
-
+
1999-08-27 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/unix/sysv/linux/netpacket/packet.h: Update from 2.3.15
diff --git a/nis/Versions b/nis/Versions
index fff3726..ec8ade0 100644
--- a/nis/Versions
+++ b/nis/Versions
@@ -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;
+ }
}
diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
index ddf777a..0ddc930 100644
--- a/nis/nss_nis/nis-hosts.c
+++ b/nis/nss_nis/nis-hosts.c
@@ -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,30 +58,30 @@ 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)
+ {
+ if (flags & AI_V4MAPPED)
+ {
+ map_v4v6_address ((char *) entdata->host_addr,
+ (char *) entdata->host_addr);
+ result->h_addrtype = AF_INET6;
+ result->h_length = IN6ADDRSZ;
+ }
+ else
+ {
+ result->h_addrtype = AF_INET;
+ 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
- if (inet_pton (AF_INET, addr, entdata->host_addr) > 0)
- {
- if (_res.options & RES_USE_INET6)
- {
- map_v4v6_address ((char *) entdata->host_addr,
- (char *) entdata->host_addr);
- result->h_addrtype = AF_INET6;
- result->h_length = IN6ADDRSZ;
- }
- else
- {
- result->h_addrtype = AF_INET;
- result->h_length = INADDRSZ;
- }
- }
- else
- /* Illegal address: ignore line. */
- return 0;
+ /* Illegal address: ignore line. */
+ return 0;
/* Store a pointer to the address in the expected form. */
entdata->h_addr_ptrs[0] = entdata->host_addr;
@@ -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)
{
@@ -323,6 +330,16 @@ _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host,
}
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);
+}
diff --git a/nis/nss_nisplus/nisplus-hosts.c b/nis/nss_nisplus/nisplus-hosts.c
index 964729c..9ca0705 100644
--- a/nis/nss_nisplus/nisplus-hosts.c
+++ b/nis/nss_nisplus/nisplus-hosts.c
@@ -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,
}
}
- 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);
+ if (_res.options & RES_USE_INET6)
+ parse_res = _nss_nisplus_parse_hostent (result, AF_INET6, host, buffer,
+ 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,
- char *buffer, size_t buflen, int *errnop,
- int *herrnop)
+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 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);
@@ -399,6 +407,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,
int *h_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)
diff --git a/nss/Versions b/nss/Versions
index 80b9ca8..a5b83b2 100644
--- a/nss/Versions
+++ b/nss/Versions
@@ -102,4 +102,7 @@ libnss_files {
_nss_files_getpublickey;
_nss_files_getsecretkey;
}
+ GLIBC_2.2 {
+ _nss_files_getipnodebyname_r;
+ }
}
diff --git a/posix/regexbug1.c b/posix/regexbug1.c
index 5758046..2864096 100644
--- a/posix/regexbug1.c
+++ b/posix/regexbug1.c
@@ -1,6 +1,7 @@
#include <error.h>
#include <sys/types.h>
#include <regex.h>
+#include <stdio.h>
#include <stdlib.h>
int
diff --git a/timezone/tst-timezone.c b/timezone/tst-timezone.c
index 5ccdb6b..edff458 100644
--- a/timezone/tst-timezone.c
+++ b/timezone/tst-timezone.c
@@ -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,