1 From a24f66c6511f863902ce12352e57643beb11acb4 Mon Sep 17 00:00:00 2001
2 From: Ruslan Bilovol <rbilovol@cisco.com>
3 Date: Mon, 11 Mar 2019 21:45:41 +0200
4 Subject: [PATCH] Include own copy of mapv4v6addr.h to be independent of used
7 The same change as was done for libnss_nis
9 Signed-off-by: Ruslan Bilovol <rbilovol@cisco.com>
11 src/Makefile.am | 3 +-
12 src/mapv4v6addr.h | 69 +++++++++++++++++++++++++++++++++++++++++++++
13 src/nisplus-hosts.c | 2 +-
14 3 files changed, 72 insertions(+), 2 deletions(-)
15 create mode 100644 src/mapv4v6addr.h
17 diff --git a/src/Makefile.am b/src/Makefile.am
18 index 37ef86c..e879d5c 100644
21 @@ -15,7 +15,8 @@ AM_CPPFLAGS = -I$(srcdir) @TIRPC_CFLAGS@ @LIBNSL_CFLAGS@
23 lib_LTLIBRARIES = libnss_nisplus.la
25 -noinst_HEADERS = libc-lock.h nss-nisplus.h netgroup.h nisplus-parser.h
26 +noinst_HEADERS = libc-lock.h nss-nisplus.h netgroup.h nisplus-parser.h \
28 check_PROGRAMS = nss_loader-test
29 nss_loader_test_LDADD = -ldl
31 diff --git a/src/mapv4v6addr.h b/src/mapv4v6addr.h
33 index 0000000..7f85f7d
35 +++ b/src/mapv4v6addr.h
38 + * ++Copyright++ 1985, 1988, 1993
40 + * Copyright (c) 1985, 1988, 1993
41 + * The Regents of the University of California. All rights reserved.
43 + * Redistribution and use in source and binary forms, with or without
44 + * modification, are permitted provided that the following conditions
46 + * 1. Redistributions of source code must retain the above copyright
47 + * notice, this list of conditions and the following disclaimer.
48 + * 2. Redistributions in binary form must reproduce the above copyright
49 + * notice, this list of conditions and the following disclaimer in the
50 + * documentation and/or other materials provided with the distribution.
51 + * 4. Neither the name of the University nor the names of its contributors
52 + * may be used to endorse or promote products derived from this software
53 + * without specific prior written permission.
55 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
56 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
58 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
59 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
60 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
61 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
62 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
63 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
64 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
67 + * Portions Copyright (c) 1993 by Digital Equipment Corporation.
69 + * Permission to use, copy, modify, and distribute this software for any
70 + * purpose with or without fee is hereby granted, provided that the above
71 + * copyright notice and this permission notice appear in all copies, and that
72 + * the name of Digital Equipment Corporation not be used in advertising or
73 + * publicity pertaining to distribution of the document or software without
74 + * specific, written prior permission.
76 + * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
77 + * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
78 + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
79 + * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
80 + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
81 + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
82 + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
89 +#include <arpa/nameser.h>
92 +map_v4v6_address (const char *src, char *dst)
94 + u_char *p = (u_char *) dst;
97 + /* Move the IPv4 part to the right position. */
98 + memcpy (dst + 12, src, INADDRSZ);
100 + /* Mark this ipv6 addr as a mapped ipv4. */
101 + for (i = 0; i < 10; i++)
106 diff --git a/src/nisplus-hosts.c b/src/nisplus-hosts.c
107 index 6e7eda5..cc00aa2 100644
108 --- a/src/nisplus-hosts.c
109 +++ b/src/nisplus-hosts.c
110 @@ -43,7 +43,7 @@ static u_long tablename_len;
111 (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len)
113 /* Get implementation for some internal functions. */
114 -#include <resolv/mapv4v6addr.h>
115 +#include "mapv4v6addr.h"
119 From 184bda40e05053cd2df61c28bec0baa7353697bb Mon Sep 17 00:00:00 2001
120 From: Khem Raj <raj.khem@gmail.com>
121 Date: Wed, 28 Aug 2019 09:49:10 -0700
122 Subject: [PATCH] nisplus-hosts: Remove use of RES_USE_INET6
124 Upstream glibc dropped it starting glibc 2.30
126 https://sourceware.org/git/?p=glibc.git;a=commit;h=3f8b44be0a658266adff5ece1e4bc3ce097a5dbe
128 Signed-off-by: Khem Raj <raj.khem@gmail.com>
130 src/Makefile.am | 3 +-
131 src/mapv4v6addr.h | 69 ---------------------------------------------
132 src/nisplus-hosts.c | 58 ++++++++-----------------------------
133 3 files changed, 13 insertions(+), 117 deletions(-)
134 delete mode 100644 src/mapv4v6addr.h
136 diff --git a/src/Makefile.am b/src/Makefile.am
137 index e879d5c..37ef86c 100644
138 --- a/src/Makefile.am
139 +++ b/src/Makefile.am
140 @@ -15,8 +15,7 @@ AM_CPPFLAGS = -I$(srcdir) @TIRPC_CFLAGS@ @LIBNSL_CFLAGS@
142 lib_LTLIBRARIES = libnss_nisplus.la
144 -noinst_HEADERS = libc-lock.h nss-nisplus.h netgroup.h nisplus-parser.h \
146 +noinst_HEADERS = libc-lock.h nss-nisplus.h netgroup.h nisplus-parser.h
147 check_PROGRAMS = nss_loader-test
148 nss_loader_test_LDADD = -ldl
150 diff --git a/src/mapv4v6addr.h b/src/mapv4v6addr.h
151 deleted file mode 100644
152 index 7f85f7d..0000000
153 --- a/src/mapv4v6addr.h
157 - * ++Copyright++ 1985, 1988, 1993
159 - * Copyright (c) 1985, 1988, 1993
160 - * The Regents of the University of California. All rights reserved.
162 - * Redistribution and use in source and binary forms, with or without
163 - * modification, are permitted provided that the following conditions
165 - * 1. Redistributions of source code must retain the above copyright
166 - * notice, this list of conditions and the following disclaimer.
167 - * 2. Redistributions in binary form must reproduce the above copyright
168 - * notice, this list of conditions and the following disclaimer in the
169 - * documentation and/or other materials provided with the distribution.
170 - * 4. Neither the name of the University nor the names of its contributors
171 - * may be used to endorse or promote products derived from this software
172 - * without specific prior written permission.
174 - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
175 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
176 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
177 - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
178 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
179 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
180 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
181 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
182 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
183 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
186 - * Portions Copyright (c) 1993 by Digital Equipment Corporation.
188 - * Permission to use, copy, modify, and distribute this software for any
189 - * purpose with or without fee is hereby granted, provided that the above
190 - * copyright notice and this permission notice appear in all copies, and that
191 - * the name of Digital Equipment Corporation not be used in advertising or
192 - * publicity pertaining to distribution of the document or software without
193 - * specific, written prior permission.
195 - * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
196 - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
197 - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
198 - * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
199 - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
200 - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
201 - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
208 -#include <arpa/nameser.h>
211 -map_v4v6_address (const char *src, char *dst)
213 - u_char *p = (u_char *) dst;
216 - /* Move the IPv4 part to the right position. */
217 - memcpy (dst + 12, src, INADDRSZ);
219 - /* Mark this ipv6 addr as a mapped ipv4. */
220 - for (i = 0; i < 10; i++)
225 diff --git a/src/nisplus-hosts.c b/src/nisplus-hosts.c
226 index cc00aa2..d37b209 100644
227 --- a/src/nisplus-hosts.c
228 +++ b/src/nisplus-hosts.c
229 @@ -42,14 +42,9 @@ static u_long tablename_len;
230 #define NISENTRYLEN(idx, col, res) \
231 (NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len)
233 -/* Get implementation for some internal functions. */
234 -#include "mapv4v6addr.h"
238 _nss_nisplus_parse_hostent (nis_result *result, int af, struct hostent *host,
239 - char *buffer, size_t buflen, int *errnop,
241 + char *buffer, size_t buflen, int *errnop)
244 char *first_unused = buffer;
245 @@ -66,8 +61,7 @@ _nss_nisplus_parse_hostent (nis_result *result, int af, struct hostent *host,
247 char *data = first_unused;
249 - if (room_left < (af != AF_INET || (flags & AI_V4MAPPED) != 0
250 - ? IN6ADDRSZ : INADDRSZ))
251 + if (room_left < INADDRSZ)
255 @@ -78,18 +72,8 @@ _nss_nisplus_parse_hostent (nis_result *result, int af, struct hostent *host,
257 && inet_pton (AF_INET, NISENTRYVAL (0, 2, result), data) > 0)
259 - assert ((flags & AI_V4MAPPED) == 0 || af != AF_UNSPEC);
260 - if (flags & AI_V4MAPPED)
262 - map_v4v6_address (data, data);
263 - host->h_addrtype = AF_INET6;
264 - host->h_length = IN6ADDRSZ;
268 - host->h_addrtype = AF_INET;
269 - host->h_length = INADDRSZ;
271 + host->h_addrtype = AF_INET;
272 + host->h_length = INADDRSZ;
274 else if (af != AF_INET
275 && inet_pton (AF_INET6, NISENTRYVAL (0, 2, result), data) > 0)
276 @@ -319,12 +303,8 @@ internal_nisplus_gethostent_r (struct hostent *host, char *buffer,
280 - if (_res.options & RES_USE_INET6)
281 - parse_res = _nss_nisplus_parse_hostent (result, AF_INET6, host, buffer,
282 - buflen, errnop, AI_V4MAPPED);
284 - parse_res = _nss_nisplus_parse_hostent (result, AF_INET, host, buffer,
285 - buflen, errnop, 0);
286 + parse_res = _nss_nisplus_parse_hostent (result, AF_INET, host, buffer,
291 @@ -379,7 +359,7 @@ get_tablename (int *herrnop)
292 static enum nss_status
293 internal_gethostbyname2_r (const char *name, int af, struct hostent *host,
294 char *buffer, size_t buflen, int *errnop,
295 - int *herrnop, int flags)
298 if (tablename_val == NULL)
300 @@ -454,7 +434,7 @@ internal_gethostbyname2_r (const char *name, int af, struct hostent *host,
303 int parse_res = _nss_nisplus_parse_hostent (result, af, host, buffer,
304 - buflen, errnop, flags);
307 nis_freeresult (result);
309 @@ -485,8 +465,7 @@ _nss_nisplus_gethostbyname2_r (const char *name, int af, struct hostent *host,
312 return internal_gethostbyname2_r (name, af, host, buffer, buflen, errnop,
314 - ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0));
319 @@ -495,19 +474,8 @@ _nss_nisplus_gethostbyname_r (const char *name, struct hostent *host,
320 char *buffer, size_t buflen, int *errnop,
323 - if (_res.options & RES_USE_INET6)
325 - enum nss_status status;
327 - status = internal_gethostbyname2_r (name, AF_INET6, host, buffer,
328 - buflen, errnop, h_errnop,
330 - if (status == NSS_STATUS_SUCCESS)
334 return internal_gethostbyname2_r (name, AF_INET, host, buffer,
335 - buflen, errnop, h_errnop, 0);
336 + buflen, errnop, h_errnop);
340 @@ -555,9 +523,7 @@ _nss_nisplus_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af,
343 parse_res = _nss_nisplus_parse_hostent (result, af, host,
344 - buffer, buflen, errnop,
345 - ((_res.options & RES_USE_INET6)
346 - ? AI_V4MAPPED : 0));
347 + buffer, buflen, errnop);
348 nis_freeresult (result);
351 @@ -584,7 +550,7 @@ _nss_nisplus_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
353 enum nss_status status = internal_gethostbyname2_r (name, AF_UNSPEC, &host,
355 - errnop, herrnop, 0);
357 if (status == NSS_STATUS_SUCCESS)