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