0001-nisplus-hosts-Remove-use-of-RES_USE_INET6.patch 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. From 184bda40e05053cd2df61c28bec0baa7353697bb Mon Sep 17 00:00:00 2001
  2. From: Khem Raj <raj.khem@gmail.com>
  3. Date: Wed, 28 Aug 2019 09:49:10 -0700
  4. Subject: [PATCH] nisplus-hosts: Remove use of RES_USE_INET6
  5. Upstream glibc dropped it starting glibc 2.30
  6. see
  7. https://sourceware.org/git/?p=glibc.git;a=commit;h=3f8b44be0a658266adff5ece1e4bc3ce097a5dbe
  8. Upstream-Status: Submitted [https://github.com/thkukuk/libnss_nisplus/pull/2]
  9. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  10. ---
  11. src/Makefile.am | 3 +-
  12. src/mapv4v6addr.h | 69 ---------------------------------------------
  13. src/nisplus-hosts.c | 58 ++++++++-----------------------------
  14. 3 files changed, 13 insertions(+), 117 deletions(-)
  15. delete mode 100644 src/mapv4v6addr.h
  16. diff --git a/src/Makefile.am b/src/Makefile.am
  17. index e879d5c..37ef86c 100644
  18. --- a/src/Makefile.am
  19. +++ b/src/Makefile.am
  20. @@ -15,8 +15,7 @@ AM_CPPFLAGS = -I$(srcdir) @TIRPC_CFLAGS@ @LIBNSL_CFLAGS@
  21. lib_LTLIBRARIES = libnss_nisplus.la
  22. -noinst_HEADERS = libc-lock.h nss-nisplus.h netgroup.h nisplus-parser.h \
  23. - mapv4v6addr.h
  24. +noinst_HEADERS = libc-lock.h nss-nisplus.h netgroup.h nisplus-parser.h
  25. check_PROGRAMS = nss_loader-test
  26. nss_loader_test_LDADD = -ldl
  27. diff --git a/src/mapv4v6addr.h b/src/mapv4v6addr.h
  28. deleted file mode 100644
  29. index 7f85f7d..0000000
  30. --- a/src/mapv4v6addr.h
  31. +++ /dev/null
  32. @@ -1,69 +0,0 @@
  33. -/*
  34. - * ++Copyright++ 1985, 1988, 1993
  35. - * -
  36. - * Copyright (c) 1985, 1988, 1993
  37. - * The Regents of the University of California. All rights reserved.
  38. - *
  39. - * Redistribution and use in source and binary forms, with or without
  40. - * modification, are permitted provided that the following conditions
  41. - * are met:
  42. - * 1. Redistributions of source code must retain the above copyright
  43. - * notice, this list of conditions and the following disclaimer.
  44. - * 2. Redistributions in binary form must reproduce the above copyright
  45. - * notice, this list of conditions and the following disclaimer in the
  46. - * documentation and/or other materials provided with the distribution.
  47. - * 4. Neither the name of the University nor the names of its contributors
  48. - * may be used to endorse or promote products derived from this software
  49. - * without specific prior written permission.
  50. - *
  51. - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  52. - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  53. - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  54. - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  55. - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  56. - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  57. - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  58. - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  59. - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  60. - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  61. - * SUCH DAMAGE.
  62. - * -
  63. - * Portions Copyright (c) 1993 by Digital Equipment Corporation.
  64. - *
  65. - * Permission to use, copy, modify, and distribute this software for any
  66. - * purpose with or without fee is hereby granted, provided that the above
  67. - * copyright notice and this permission notice appear in all copies, and that
  68. - * the name of Digital Equipment Corporation not be used in advertising or
  69. - * publicity pertaining to distribution of the document or software without
  70. - * specific, written prior permission.
  71. - *
  72. - * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
  73. - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
  74. - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
  75. - * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  76. - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  77. - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  78. - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  79. - * SOFTWARE.
  80. - * -
  81. - * --Copyright--
  82. - */
  83. -
  84. -#include <string.h>
  85. -#include <arpa/nameser.h>
  86. -
  87. -static void
  88. -map_v4v6_address (const char *src, char *dst)
  89. -{
  90. - u_char *p = (u_char *) dst;
  91. - int i;
  92. -
  93. - /* Move the IPv4 part to the right position. */
  94. - memcpy (dst + 12, src, INADDRSZ);
  95. -
  96. - /* Mark this ipv6 addr as a mapped ipv4. */
  97. - for (i = 0; i < 10; i++)
  98. - *p++ = 0x00;
  99. - *p++ = 0xff;
  100. - *p = 0xff;
  101. -}
  102. diff --git a/src/nisplus-hosts.c b/src/nisplus-hosts.c
  103. index cc00aa2..d37b209 100644
  104. --- a/src/nisplus-hosts.c
  105. +++ b/src/nisplus-hosts.c
  106. @@ -42,14 +42,9 @@ static u_long tablename_len;
  107. #define NISENTRYLEN(idx, col, res) \
  108. (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len)
  109. -/* Get implementation for some internal functions. */
  110. -#include "mapv4v6addr.h"
  111. -
  112. -
  113. static int
  114. _nss_nisplus_parse_hostent (nis_result *result, int af, struct hostent *host,
  115. - char *buffer, size_t buflen, int *errnop,
  116. - int flags)
  117. + char *buffer, size_t buflen, int *errnop)
  118. {
  119. unsigned int i;
  120. char *first_unused = buffer;
  121. @@ -66,8 +61,7 @@ _nss_nisplus_parse_hostent (nis_result *result, int af, struct hostent *host,
  122. char *data = first_unused;
  123. - if (room_left < (af != AF_INET || (flags & AI_V4MAPPED) != 0
  124. - ? IN6ADDRSZ : INADDRSZ))
  125. + if (room_left < INADDRSZ)
  126. {
  127. no_more_room:
  128. *errnop = ERANGE;
  129. @@ -78,18 +72,8 @@ _nss_nisplus_parse_hostent (nis_result *result, int af, struct hostent *host,
  130. if (af != AF_INET6
  131. && inet_pton (AF_INET, NISENTRYVAL (0, 2, result), data) > 0)
  132. {
  133. - assert ((flags & AI_V4MAPPED) == 0 || af != AF_UNSPEC);
  134. - if (flags & AI_V4MAPPED)
  135. - {
  136. - map_v4v6_address (data, data);
  137. - host->h_addrtype = AF_INET6;
  138. - host->h_length = IN6ADDRSZ;
  139. - }
  140. - else
  141. - {
  142. - host->h_addrtype = AF_INET;
  143. - host->h_length = INADDRSZ;
  144. - }
  145. + host->h_addrtype = AF_INET;
  146. + host->h_length = INADDRSZ;
  147. }
  148. else if (af != AF_INET
  149. && inet_pton (AF_INET6, NISENTRYVAL (0, 2, result), data) > 0)
  150. @@ -319,12 +303,8 @@ internal_nisplus_gethostent_r (struct hostent *host, char *buffer,
  151. }
  152. }
  153. - if (_res.options & RES_USE_INET6)
  154. - parse_res = _nss_nisplus_parse_hostent (result, AF_INET6, host, buffer,
  155. - buflen, errnop, AI_V4MAPPED);
  156. - else
  157. - parse_res = _nss_nisplus_parse_hostent (result, AF_INET, host, buffer,
  158. - buflen, errnop, 0);
  159. + parse_res = _nss_nisplus_parse_hostent (result, AF_INET, host, buffer,
  160. + buflen, errnop);
  161. if (parse_res == -1)
  162. {
  163. @@ -379,7 +359,7 @@ get_tablename (int *herrnop)
  164. static enum nss_status
  165. internal_gethostbyname2_r (const char *name, int af, struct hostent *host,
  166. char *buffer, size_t buflen, int *errnop,
  167. - int *herrnop, int flags)
  168. + int *herrnop)
  169. {
  170. if (tablename_val == NULL)
  171. {
  172. @@ -454,7 +434,7 @@ internal_gethostbyname2_r (const char *name, int af, struct hostent *host,
  173. }
  174. int parse_res = _nss_nisplus_parse_hostent (result, af, host, buffer,
  175. - buflen, errnop, flags);
  176. + buflen, errnop);
  177. nis_freeresult (result);
  178. @@ -485,8 +465,7 @@ _nss_nisplus_gethostbyname2_r (const char *name, int af, struct hostent *host,
  179. }
  180. return internal_gethostbyname2_r (name, af, host, buffer, buflen, errnop,
  181. - herrnop,
  182. - ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0));
  183. + herrnop);
  184. }
  185. @@ -495,19 +474,8 @@ _nss_nisplus_gethostbyname_r (const char *name, struct hostent *host,
  186. char *buffer, size_t buflen, int *errnop,
  187. int *h_errnop)
  188. {
  189. - if (_res.options & RES_USE_INET6)
  190. - {
  191. - enum nss_status status;
  192. -
  193. - status = internal_gethostbyname2_r (name, AF_INET6, host, buffer,
  194. - buflen, errnop, h_errnop,
  195. - AI_V4MAPPED);
  196. - if (status == NSS_STATUS_SUCCESS)
  197. - return status;
  198. - }
  199. -
  200. return internal_gethostbyname2_r (name, AF_INET, host, buffer,
  201. - buflen, errnop, h_errnop, 0);
  202. + buflen, errnop, h_errnop);
  203. }
  204. @@ -555,9 +523,7 @@ _nss_nisplus_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af,
  205. }
  206. parse_res = _nss_nisplus_parse_hostent (result, af, host,
  207. - buffer, buflen, errnop,
  208. - ((_res.options & RES_USE_INET6)
  209. - ? AI_V4MAPPED : 0));
  210. + buffer, buflen, errnop);
  211. nis_freeresult (result);
  212. if (parse_res > 0)
  213. @@ -584,7 +550,7 @@ _nss_nisplus_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
  214. enum nss_status status = internal_gethostbyname2_r (name, AF_UNSPEC, &host,
  215. buffer, buflen,
  216. - errnop, herrnop, 0);
  217. + errnop, herrnop);
  218. if (status == NSS_STATUS_SUCCESS)
  219. {
  220. if (*pat == NULL)
  221. --
  222. 2.23.0