about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2019-05-16 17:23:23 +0200
committerFlorian Weimer <fweimer@redhat.com>2019-05-16 17:23:23 +0200
commitec255a97a22c0b46c111ff0f10be2beb9b5d9224 (patch)
tree00ddfc520c00edc73c1bec17a4f16fbb99fa565c
parent9c02d0784dfa0bb4b0bfec4fb6db35d3ea953288 (diff)
downloadglibc-ec255a97a22c0b46c111ff0f10be2beb9b5d9224.tar.gz
glibc-ec255a97a22c0b46c111ff0f10be2beb9b5d9224.tar.xz
glibc-ec255a97a22c0b46c111ff0f10be2beb9b5d9224.zip
nss_nis, nss_nisplus: Remove RES_USE_INET6 handling
Since commit 3f8b44be0a658266adff5ece1e4bc3ce097a5dbe ("resolv:
Remove support for RES_USE_INET6 and the inet6 option"),
res_use_inet6 () always evaluates to false.
-rw-r--r--ChangeLog33
-rw-r--r--nis/nss_nis/nis-hosts.c55
-rw-r--r--nis/nss_nisplus/nisplus-hosts.c59
3 files changed, 58 insertions, 89 deletions
diff --git a/ChangeLog b/ChangeLog
index 74f038ec36..cb020262d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,38 @@
 2019-05-16  Florian Weimer  <fweimer@redhat.com>
 
+	* nis/nss_nis/nis-hosts.c (EXTRA_ARGS, EXTRA_ARGS_DECL): Remove
+	flags argument.
+	(LINE_PARSER): Do not map IPv4 addresses.
+	(internal_nis_gethostent_r): Remove flags argument.  Adjust call
+	to parse_line.
+	(_nss_nis_gethostent_r): Always pass AF_INET to
+	internal_nis_gethostent_r.
+	(internal_gethostbyname2_r): Remove flags argument.  Adjust call
+	to parse_line.
+	(_nss_nis_gethostbyname2_r): Adjust call to
+	internal_nis_gethostent_r.
+	(_nss_nis_gethostbyname_r): Do not attempt IPv6 query.  Adjust
+	call to internal_nis_gethostent_r.
+	(_nss_nis_gethostbyaddr_r): Do not request IPv4 address mapping
+	from parse_line.
+	(_nss_nis_gethostbyname4_r):Adjust call to parse_line.
+	* nis/nss_nisplus/nisplus-hosts.c (_nss_nisplus_parse_hostent):
+	Remove flags argument.  Do not map IPv4 addresses.
+	(internal_nisplus_gethostent_r): Adjust call to
+	_nss_nisplus_parse_hostent.
+	(internal_gethostbyname2_r): Remove flags argument.  Adjust call
+	to _nss_nisplus_parse_hostent.
+	(_nss_nisplus_gethostbyname2_r): Adjust call to
+	internal_gethostbyname2_r.
+	(_nss_nisplus_gethostbyname_r): Do not perform IPv6 lookup.
+	Adjust call to internal_gethostbyname2_r.
+	(_nss_nisplus_gethostbyaddr_r): Adjust call to
+	_nss_nisplus_parse_hostent.
+	(_nss_nisplus_gethostbyname4_r): Adjust call to
+	internal_gethostbyname2_r.
+
+2019-05-16  Florian Weimer  <fweimer@redhat.com>
+
 	* nss/nss_files/files-hosts.c (EXTRA_ARGS, EXTRA_ARGS_DECL):
 	Remove flags.
 	(LINE_PARSER): Remove address mapping.
diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
index f49c418f36..d70973dcee 100644
--- a/nis/nss_nis/nis-hosts.c
+++ b/nis/nss_nis/nis-hosts.c
@@ -27,22 +27,18 @@
 #include <string.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
-#include <resolv/resolv-internal.h>
 #include <libc-lock.h>
 #include <rpcsvc/yp.h>
 #include <rpcsvc/ypclnt.h>
 
 #include "nss-nis.h"
 
-/* Get implementation for some internal functions. */
-#include <resolv/mapv4v6addr.h>
-
 #define ENTNAME         hostent
 #define DATABASE        "hosts"
 #define NEED_H_ERRNO
 
-#define EXTRA_ARGS      , af, flags
-#define EXTRA_ARGS_DECL , int af, int flags
+#define EXTRA_ARGS      , af
+#define EXTRA_ARGS_DECL , int af
 
 #define ENTDATA hostent_data
 struct hostent_data
@@ -66,19 +62,8 @@ LINE_PARSER
    /* Parse address.  */
    if (af != AF_INET6 && inet_pton (AF_INET, addr, entdata->host_addr) > 0)
      {
-       assert ((flags & AI_V4MAPPED) == 0 || af != AF_UNSPEC);
-       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;
-	 }
+       result->h_addrtype = AF_INET;
+       result->h_length = INADDRSZ;
      }
    else if (af != AF_INET
 	    && inet_pton (AF_INET6, addr, entdata->host_addr) > 0)
@@ -133,7 +118,7 @@ strong_alias (_nss_nis_sethostent, _nss_nis_endhostent)
 static enum nss_status
 internal_nis_gethostent_r (struct hostent *host, char *buffer,
 			   size_t buflen, int *errnop, int *h_errnop,
-			   int af, int flags)
+			   int af)
 {
   char *domain;
   if (__glibc_unlikely (yp_get_default_domain (&domain)))
@@ -202,7 +187,7 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer,
 	++p;
       free (result);
 
-      parse_res = parse_line (p, host, data, buflen, errnop, af, flags);
+      parse_res = parse_line (p, host, data, buflen, errnop, af);
       if (__glibc_unlikely (parse_res == -1))
 	{
 	  free (outkey);
@@ -231,8 +216,7 @@ _nss_nis_gethostent_r (struct hostent *host, char *buffer, size_t buflen,
   __libc_lock_lock (lock);
 
   status = internal_nis_gethostent_r (host, buffer, buflen, errnop, h_errnop,
-			(res_use_inet6 () ? AF_INET6 : AF_INET),
-			(res_use_inet6 () ? AI_V4MAPPED : 0 ));
+				      AF_INET);
 
   __libc_lock_unlock (lock);
 
@@ -243,7 +227,7 @@ _nss_nis_gethostent_r (struct hostent *host, char *buffer, size_t buflen,
 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 flags)
+			   int *h_errnop)
 {
   uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct parser_data);
   buffer += pad;
@@ -317,7 +301,7 @@ internal_gethostbyname2_r (const char *name, int af, struct hostent *host,
     ++p;
   free (result);
 
-  int parse_res = parse_line (p, host, data, buflen, errnop, af, flags);
+  int parse_res = parse_line (p, host, data, buflen, errnop, af);
 
   if (__glibc_unlikely (parse_res < 1 || host->h_addrtype != af))
     {
@@ -350,8 +334,7 @@ _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host,
     }
 
   return internal_gethostbyname2_r (name, af, host, buffer, buflen, errnop,
-				    h_errnop,
-			(res_use_inet6 () ? AI_V4MAPPED : 0));
+				    h_errnop);
 }
 
 
@@ -359,18 +342,8 @@ enum nss_status
 _nss_nis_gethostbyname_r (const char *name, struct hostent *host, char *buffer,
 			  size_t buflen, int *errnop, int *h_errnop)
 {
-  if (res_use_inet6 ())
-    {
-      enum nss_status status;
-
-      status = internal_gethostbyname2_r (name, AF_INET6, host, buffer, buflen,
-					  errnop, h_errnop, AI_V4MAPPED);
-      if (status == NSS_STATUS_SUCCESS)
-	return status;
-    }
-
   return internal_gethostbyname2_r (name, AF_INET, host, buffer, buflen,
-				    errnop, h_errnop, 0);
+				    errnop, h_errnop);
 }
 
 
@@ -432,8 +405,7 @@ _nss_nis_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af,
     ++p;
   free (result);
 
-  int parse_res = parse_line (p, host, data, buflen, errnop, af,
-			      (res_use_inet6 () ? AI_V4MAPPED : 0));
+  int parse_res = parse_line (p, host, data, buflen, errnop, af);
   if (__glibc_unlikely (parse_res < 1))
     {
       if (parse_res == -1)
@@ -530,8 +502,7 @@ _nss_nis_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
   buflen -= pad;
 
   struct hostent host;
-  int parse_res = parse_line (result, &host, data, buflen, errnop, AF_UNSPEC,
-			      0);
+  int parse_res = parse_line (result, &host, data, buflen, errnop, AF_UNSPEC);
   if (__glibc_unlikely (parse_res < 1))
     {
       if (parse_res == -1)
diff --git a/nis/nss_nisplus/nisplus-hosts.c b/nis/nss_nisplus/nisplus-hosts.c
index 2249966e97..81ebd9f0d6 100644
--- a/nis/nss_nisplus/nisplus-hosts.c
+++ b/nis/nss_nisplus/nisplus-hosts.c
@@ -42,15 +42,9 @@ static u_long tablename_len;
 #define NISENTRYLEN(idx, col, res) \
 	(NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len)
 
-/* Get implementation for some internal functions. */
-#include <resolv/resolv-internal.h>
-#include <resolv/mapv4v6addr.h>
-
-
 static int
 _nss_nisplus_parse_hostent (nis_result *result, int af, struct hostent *host,
-			    char *buffer, size_t buflen, int *errnop,
-			    int flags)
+			    char *buffer, size_t buflen, int *errnop)
 {
   unsigned int i;
   char *first_unused = buffer;
@@ -67,8 +61,7 @@ _nss_nisplus_parse_hostent (nis_result *result, int af, struct hostent *host,
 
   char *data = first_unused;
 
-  if (room_left < (af != AF_INET || (flags & AI_V4MAPPED) != 0
-		   ? IN6ADDRSZ : INADDRSZ))
+  if (room_left < (af != AF_INET ? IN6ADDRSZ : INADDRSZ))
     {
     no_more_room:
       *errnop = ERANGE;
@@ -79,18 +72,8 @@ _nss_nisplus_parse_hostent (nis_result *result, int af, struct hostent *host,
   if (af != AF_INET6
       && inet_pton (AF_INET, NISENTRYVAL (0, 2, result), data) > 0)
     {
-      assert ((flags & AI_V4MAPPED) == 0 || af != AF_UNSPEC);
-      if (flags & AI_V4MAPPED)
-	{
-	  map_v4v6_address (data, data);
-	  host->h_addrtype = AF_INET6;
-	  host->h_length = IN6ADDRSZ;
-	}
-      else
-	{
-	  host->h_addrtype = AF_INET;
-	  host->h_length = INADDRSZ;
-	}
+      host->h_addrtype = AF_INET;
+      host->h_length = INADDRSZ;
     }
   else if (af != AF_INET
 	   && inet_pton (AF_INET6, NISENTRYVAL (0, 2, result), data) > 0)
@@ -322,12 +305,8 @@ internal_nisplus_gethostent_r (struct hostent *host, char *buffer,
 	    }
 	}
 
-      if (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);
+      parse_res = _nss_nisplus_parse_hostent (result, AF_INET, host, buffer,
+					      buflen, errnop);
 
       if (parse_res == -1)
 	{
@@ -382,7 +361,7 @@ get_tablename (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 *herrnop)
 {
   if (tablename_val == NULL)
     {
@@ -457,7 +436,7 @@ internal_gethostbyname2_r (const char *name, int af, struct hostent *host,
     }
 
   int parse_res = _nss_nisplus_parse_hostent (result, af, host, buffer,
-					      buflen, errnop, flags);
+					      buflen, errnop);
 
   nis_freeresult (result);
 
@@ -488,8 +467,7 @@ _nss_nisplus_gethostbyname2_r (const char *name, int af, struct hostent *host,
     }
 
   return internal_gethostbyname2_r (name, af, host, buffer, buflen, errnop,
-				    herrnop,
-				    (res_use_inet6 () ? AI_V4MAPPED : 0));
+				    herrnop);
 }
 
 
@@ -498,19 +476,8 @@ _nss_nisplus_gethostbyname_r (const char *name, struct hostent *host,
 			      char *buffer, size_t buflen, int *errnop,
 			      int *h_errnop)
 {
-  if (res_use_inet6 ())
-    {
-      enum nss_status status;
-
-      status = internal_gethostbyname2_r (name, AF_INET6, host, buffer,
-					  buflen, errnop, h_errnop,
-					  AI_V4MAPPED);
-      if (status == NSS_STATUS_SUCCESS)
-	return status;
-    }
-
   return internal_gethostbyname2_r (name, AF_INET, host, buffer,
-				   buflen, errnop, h_errnop, 0);
+				   buflen, errnop, h_errnop);
 }
 
 
@@ -558,9 +525,7 @@ _nss_nisplus_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af,
     }
 
   parse_res = _nss_nisplus_parse_hostent (result, af, host,
-					  buffer, buflen, errnop,
-					  (res_use_inet6 ()
-					   ? AI_V4MAPPED : 0));
+					  buffer, buflen, errnop);
   nis_freeresult (result);
 
   if (parse_res > 0)
@@ -587,7 +552,7 @@ _nss_nisplus_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
 
   enum nss_status status = internal_gethostbyname2_r (name, AF_UNSPEC, &host,
 						      buffer, buflen,
-						      errnop, herrnop, 0);
+						      errnop, herrnop);
   if (__glibc_likely (status == NSS_STATUS_SUCCESS))
     {
       if (*pat == NULL)