diff options
| author | Florian Weimer <fweimer@redhat.com> | 2019-04-08 10:40:31 +0200 |
|---|---|---|
| committer | Florian Weimer <fweimer@redhat.com> | 2019-04-08 10:56:22 +0200 |
| commit | 3f8b44be0a658266adff5ece1e4bc3ce097a5dbe (patch) | |
| tree | 060ffb11ccd5433902b8c60c3e80dc0f140ec55d | |
| parent | 94e358f6d490650c714edb1ffc3a52f56ffe086e (diff) | |
| download | glibc-3f8b44be0a658266adff5ece1e4bc3ce097a5dbe.tar.xz glibc-3f8b44be0a658266adff5ece1e4bc3ce097a5dbe.zip | |
resolv: Remove support for RES_USE_INET6 and the inet6 option
This functionality was deprecated in glibc 2.25.
This commit only includes the core changes to remove the
functionality. It does not remove the RES_USE_INET6 handling in the
individual NSS service modules and the res_use_inet6 function.
These changes will happen in future commits.
| -rw-r--r-- | ChangeLog | 37 | ||||
| -rw-r--r-- | NEWS | 3 | ||||
| -rw-r--r-- | nscd/aicache.c | 8 | ||||
| -rw-r--r-- | nscd/nscd_gethst_r.c | 6 | ||||
| -rw-r--r-- | resolv/Makefile | 11 | ||||
| -rw-r--r-- | resolv/res_debug.c | 1 | ||||
| -rw-r--r-- | resolv/res_init.c | 1 | ||||
| -rw-r--r-- | resolv/res_use_inet6.h | 49 | ||||
| -rw-r--r-- | resolv/resolv-internal.h | 9 | ||||
| -rw-r--r-- | resolv/resolv.h | 2 | ||||
| -rw-r--r-- | resolv/resolv_context.h | 11 | ||||
| -rw-r--r-- | resolv/tst-res_use_inet6.c | 509 | ||||
| -rw-r--r-- | resolv/tst-resolv-res_init-skeleton.c | 4 | ||||
| -rw-r--r-- | resolv/tst-resolv-threads.c | 79 | ||||
| -rw-r--r-- | sysdeps/posix/getaddrinfo.c | 11 |
15 files changed, 61 insertions, 680 deletions
@@ -1,3 +1,40 @@ +2019-04-08 Florian Weimer <fweimer@redhat.com> + + resolv: Remove support for RES_USE_INET6 and the inet6 option. + * nscd/aicache.c (addhstaiX): Do not disable RES_USE_INET6. + * nscd/nscd_gehst_r.c (__nscd_gethostbyname_r): Always use + GETHOSTBYNAME. + * resolv/Makefile (tests): Remove tst-res_use_inet6. + (tests-internal): Update justification for tst-resolv-res_init, + tst-resolv-res_init-thread. + (tst-res_use_inet6): Remove target. + (CFLAGS-tst-res_use_inet6.c): Do not set variable. + * resolv/res_debug.c (p_option): Remove "inet6" support. + * resolv/res_init.c (res_setoptions): Likewise. + * resolv/res_use_inet6.h: Remove file. + * resolv/resolv-internal.h (DEPRECATED_RES_USE_INET6): Remove + definition. + (res_use_inet6): Always return false. + * resolv/resolv.h (RES_USE_INET6): Remove definition. + * resolv/resolv_context.h: Adjust file comment. + (struct resolv_context): Update comment on __next field. + (__resolv_context_put): Update comment. + * resolv/tst-res_use_inet6.c: Remove file. + * resolv/tst-resolv-res_init-skeleton.c (print_resp): Remove + "inet6" support. + (test_cases): Adjust test case. + * resolv/tst-resolv-threads.c (byname_inet6) Remove function. + (thread_byname2_af_inet6): Use old byname_inet6 code. + (thread_byname_inet6, thread_byname2_af_inet6): Remove functions. + (gai): Remove do_inet6 argument. + (thread_gai_inet, thread_gai_inet6, thread_gai_unspec): Adjust. + (thread_gai_inet_inet6, thread_gai_inet6_inet6) + (thread_gai_unspec_inet6): Remove functions. + (do_test): Adjust thread_funcs. + * sysdeps/posix/getaddrinfo.c (gethosts): Do not restore + RES_USE_INET6 flag. + (gaih_inet): Do not disable RES_USE_INET6 flag. + 2019-04-05 Anton Youdkevitch <anton.youdkevitch@bell-sw.com> * sysdeps/aarch64/multiarch/memcpy_thunderx2.S: Cleanup branching @@ -35,6 +35,9 @@ Deprecated and removed features, and other changes affecting compatibility: * The obsolete and never-implemented XSI STREAMS header files <stropts.h> and <sys/stropts.h> have been removed. +* Support for the "inet6" option in /etc/resolv.conf and the RES_USE_INET6 + resolver flag (deprecated in glibc 2.25) have been removed. + Changes to build and runtime requirements: * GCC 6.2 or later is required to build the GNU C Library. diff --git a/nscd/aicache.c b/nscd/aicache.c index cf9b91d149..5b94e2aa9e 100644 --- a/nscd/aicache.c +++ b/nscd/aicache.c @@ -27,7 +27,6 @@ #include <sys/mman.h> #include <resolv/resolv-internal.h> #include <resolv/resolv_context.h> -#include <resolv/res_use_inet6.h> #include <scratch_buffer.h> #include "dbg_log.h" @@ -100,12 +99,8 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, no_more = 0; nip = hosts_database; - /* Initialize configurations. If we are looking for both IPv4 and - IPv6 address we don't want the lookup functions to automatically - promote IPv4 addresses to IPv6 addresses. Therefore, use the - _no_inet6 variant. */ + /* Initialize configurations. */ struct resolv_context *ctx = __resolv_context_get (); - bool enable_inet6 = __resolv_context_disable_inet6 (ctx); if (ctx == NULL) no_more = 1; @@ -513,7 +508,6 @@ next_nip: } out: - __resolv_context_enable_inet6 (ctx, enable_inet6); __resolv_context_put (ctx); if (dataset != NULL && !alloca_used) diff --git a/nscd/nscd_gethst_r.c b/nscd/nscd_gethst_r.c index 97c6190c95..f4c5849862 100644 --- a/nscd/nscd_gethst_r.c +++ b/nscd/nscd_gethst_r.c @@ -40,11 +40,7 @@ __nscd_gethostbyname_r (const char *name, struct hostent *resultbuf, char *buffer, size_t buflen, struct hostent **result, int *h_errnop) { - request_type reqtype; - - reqtype = res_use_inet6 () ? GETHOSTBYNAMEv6 : GETHOSTBYNAME; - - return nscd_gethst_r (name, strlen (name) + 1, reqtype, resultbuf, + return nscd_gethst_r (name, strlen (name) + 1, GETHOSTBYNAME, resultbuf, buffer, buflen, result, h_errnop); } diff --git a/resolv/Makefile b/resolv/Makefile index ebe1b733f2..3f84443742 100644 --- a/resolv/Makefile +++ b/resolv/Makefile @@ -52,7 +52,6 @@ tests += \ tst-ns_name_pton \ tst-res_hconf_reorder \ tst-res_hnok \ - tst-res_use_inet6 \ tst-resolv-basic \ tst-resolv-binary \ tst-resolv-edns \ @@ -70,13 +69,10 @@ tests += \ tst-resolv-ai_idn-nolibidn2 \ tst-resolv-canonname \ -# uses DEPRECATED_RES_USE_INET6 from <resolv-internal.h>. +# Needs resolv_context. tests-internal += \ tst-resolv-res_init \ tst-resolv-res_init-thread \ - -# Needs resolv_context. -tests-internal += \ tst-resolv-res_ninit \ tst-resolv-threads \ @@ -175,7 +171,6 @@ $(objpfx)mtrace-tst-resolv-res_ninit.out: $(objpfx)tst-resolv-res_ninit.out $(objpfx)tst-bug18665-tcp: $(objpfx)libresolv.so $(shared-thread-library) $(objpfx)tst-bug18665: $(objpfx)libresolv.so $(shared-thread-library) -$(objpfx)tst-res_use_inet6: $(objpfx)libresolv.so $(shared-thread-library) $(objpfx)tst-resolv-ai_idn: \ $(libdl) $(objpfx)libresolv.so $(shared-thread-library) $(objpfx)tst-resolv-ai_idn-latin1: \ @@ -211,7 +206,3 @@ $(objpfx)tst-ns_name_compress: $(objpfx)libresolv.so $(objpfx)tst-ns_name_pton: $(objpfx)libresolv.so $(objpfx)tst-res_hnok: $(objpfx)libresolv.so $(objpfx)tst-p_secstodate: $(objpfx)libresolv.so - - -# This test case uses the deprecated RES_USE_INET6 resolver option. -CFLAGS-tst-res_use_inet6.c += -Wno-error diff --git a/resolv/res_debug.c b/resolv/res_debug.c index 7681ad4639..e4664c1da6 100644 --- a/resolv/res_debug.c +++ b/resolv/res_debug.c @@ -607,7 +607,6 @@ p_option(u_long option) { case RES_INSECURE1: return "insecure1"; case RES_INSECURE2: return "insecure2"; case RES_NOALIASES: return "noaliases"; - case DEPRECATED_RES_USE_INET6: return "inet6"; case RES_ROTATE: return "rotate"; case RES_USE_EDNS0: return "edns0"; case RES_SNGLKUP: return "single-request"; diff --git a/resolv/res_init.c b/resolv/res_init.c index 265e3cc6e3..936fbcb7bd 100644 --- a/resolv/res_init.c +++ b/resolv/res_init.c @@ -672,7 +672,6 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options) unsigned long int flag; } options[] = { #define STRnLEN(str) str, sizeof (str) - 1 - { STRnLEN ("inet6"), 0, DEPRECATED_RES_USE_INET6 }, { STRnLEN ("rotate"), 0, RES_ROTATE }, { STRnLEN ("edns0"), 0, RES_USE_EDNS0 }, { STRnLEN ("single-request-reopen"), 0, RES_SNGLKUPREOP }, diff --git a/resolv/res_use_inet6.h b/resolv/res_use_inet6.h deleted file mode 100644 index a4ed9c34bb..0000000000 --- a/resolv/res_use_inet6.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Support functions for handling RES_USE_INET6 in getaddrinfo/nscd. - Copyright (C) 2017-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#ifndef _RES_USE_INET6_H -#define _RES_USE_INET6_H - -#include <resolv/resolv_context.h> -#include <resolv/resolv-internal.h> - -/* Ensure that RES_USE_INET6 is disabled in *CTX. Return true if - __resolv_context_enable_inet6 below should enable RES_USE_INET6 - again. */ -static inline bool -__resolv_context_disable_inet6 (struct resolv_context *ctx) -{ - if (ctx != NULL && ctx->resp->options & DEPRECATED_RES_USE_INET6) - { - ctx->resp->options &= ~DEPRECATED_RES_USE_INET6; - return true; - } - else - return false; -} - -/* If ENABLE, re-enable RES_USE_INET6 in *CTX. To be paired with - __resolv_context_disable_inet6. */ -static inline void -__resolv_context_enable_inet6 (struct resolv_context *ctx, bool enable) -{ - if (ctx != NULL && enable) - ctx->resp->options |= DEPRECATED_RES_USE_INET6; -} - -#endif diff --git a/resolv/resolv-internal.h b/resolv/resolv-internal.h index 1500adc607..3aca6804f4 100644 --- a/resolv/resolv-internal.h +++ b/resolv/resolv-internal.h @@ -27,15 +27,12 @@ #define RES_F_CONN 0x00000002 /* Socket is connected. */ #define RES_F_EDNS0ERR 0x00000004 /* EDNS0 caused errors. */ - -/* Internal version of RES_USE_INET6 which does not trigger a - deprecation warning. */ -#define DEPRECATED_RES_USE_INET6 0x00002000 - +/* Legacy function. This needs to be removed once all NSS modules + have been adjusted. */ static inline bool res_use_inet6 (void) { - return _res.options & DEPRECATED_RES_USE_INET6; + return false; } enum diff --git a/resolv/resolv.h b/resolv/resolv.h index 80a523e5e4..ad053d9d14 100644 --- a/resolv/resolv.h +++ b/resolv/resolv.h @@ -118,8 +118,6 @@ struct res_sym { #define RES_INSECURE1 0x00000400 /* type 1 security disabled */ #define RES_INSECURE2 0x00000800 /* type 2 security disabled */ #define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */ -#define RES_USE_INET6 \ - __glibc_macro_warning ("RES_USE_INET6 is deprecated") 0x00002000 #define RES_ROTATE 0x00004000 /* rotate ns list after each query */ #define RES_NOCHECKNAME \ __glibc_macro_warning ("RES_NOCHECKNAME is deprecated") 0x00008000 diff --git a/resolv/resolv_context.h b/resolv/resolv_context.h index a4d97738a7..b1114343e6 100644 --- a/resolv/resolv_context.h +++ b/resolv/resolv_context.h @@ -26,9 +26,7 @@ allocating a new context. This prevents unexpected reloading of the resolver configuration. Care is taken to keep the context in sync with the thread-local _res object. (This does not happen with - __resolv_context_get_override, and __resolv_context_get_no_inet6 may - also interpose another context object if RES_USE_INET6 needs to be - disabled.) + __resolv_context_get_override.) In contrast to struct __res_state, struct resolv_context is not affected by ABI compatibility concerns. @@ -62,8 +60,8 @@ struct resolv_context size_t __refcount; /* Count of reusages by the get functions. */ bool __from_res; /* True if created from _res. */ - /* If RES_USE_INET6 was disabled at this level, this field points to - the previous context. */ + /* Single-linked list of resolver contexts. Used for memory + deallocation on thread cancellation. */ struct resolv_context *__next; }; @@ -75,8 +73,7 @@ struct resolv_context *__resolv_context_get (void) libc_hidden_proto (__resolv_context_get) /* Deallocate the temporary resolver context. Converse of - __resolv_context_get. Restore the RES_USE_INET6 flag if necessary. - Do nothing if CTX is NULL. */ + __resolv_context_get. Do nothing if CTX is NULL. */ void __resolv_context_put (struct resolv_context *ctx); libc_hidden_proto (__resolv_context_put) diff --git a/resolv/tst-res_use_inet6.c b/resolv/tst-res_use_inet6.c deleted file mode 100644 index 65145b7b1f..0000000000 --- a/resolv/tst-res_use_inet6.c +++ /dev/null @@ -1,509 +0,0 @@ -/* Basic functionality tests for inet6 option processing. - Copyright (C) 2016-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <ctype.h> -#include <netdb.h> -#include <resolv.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <support/check.h> -#include <support/check_nss.h> -#include <support/resolv_test.h> -#include <support/support.h> -#include <support/xthread.h> - -/* Handle IPv4 reverse lookup responses. Product a PTR record - A-B-C-D.v4.example. */ -static void -response_ptr_v4 (const struct resolv_response_context *ctx, - struct resolv_response_builder *b, - const char *qname, uint16_t qclass, uint16_t qtype) -{ - int bytes[4]; - int offset = -1; - TEST_VERIFY (sscanf (qname, "%d.%d.%d.%d.in-addr.arpa%n", - bytes + 0, bytes + 1, bytes + 2, bytes + 3, - &offset) == 4); - TEST_VERIFY (offset == strlen (qname)); - resolv_response_init (b, (struct resolv_response_flags) {}); - resolv_response_add_question (b, qname, qclass, qtype); - resolv_response_section (b, ns_s_an); - resolv_response_open_record (b, qname, qclass, T_PTR, 0); - char *name = xasprintf ("%d-%d-%d-%d.v4.example", - bytes[3], bytes[2], bytes[1], bytes[0]); - resolv_response_add_name (b, name); - free (name); - resolv_response_close_record (b); -} - -/* Handle IPv6 reverse lookup responses. Produce a PTR record - <32 hex digits>.v6.example. */ -static void -response_ptr_v6 (const struct resolv_response_context *ctx, - struct resolv_response_builder *b, - const char *qname, uint16_t qclass, uint16_t qtype) -{ - - TEST_VERIFY_EXIT (strlen (qname) > 64); - - char bytes[33]; - for (int i = 0; i < 64; ++i) - if ((i % 2) == 0) - { - TEST_VERIFY (isxdigit ((unsigned char) qname[i])); - bytes[31 - i / 2] = qname[i]; - } - else - TEST_VERIFY_EXIT (qname[i] == '.'); - bytes[32] = '\0'; - - resolv_response_init (b, (struct resolv_response_flags) {}); - resolv_response_add_question (b, qname, qclass, qtype); - resolv_response_section (b, ns_s_an); - resolv_response_open_record (b, qname, qclass, T_PTR, 0); - char *name = xasprintf ("%s.v6.example", bytes); - resolv_response_add_name (b, name); - free (name); - resolv_response_close_record (b); -} - -/* Produce a response based on QNAME: Certain characters in the first - label of QNAME trigger the inclusion of resource records: - - 'a' A record (IPv4 address) - 'q' AAAA record (quad A record, IPv6 address) - 'p' PTR record - 'm' record type must match QTYPE (no additional records) - '6' stop flag processing if QTYPE == AAAA - - For 'a' and 'q', QTYPE is ignored for record type selection if 'm' - is not specified. - - in-addr.arpa and ip6.arpa queries are handled separately in - response_ptr_v4 and response_ptr_v6. */ -static void -response (const struct resolv_response_context *ctx, - struct resolv_response_builder *b, - const char *qname, uint16_t qclass, uint16_t qtype) -{ - if (strstr (qname, ".in-addr.arpa") != NULL) - return response_ptr_v4 (ctx, b, qname, qclass, qtype); - else if (strstr (qname, ".ip6.arpa") != NULL) - return response_ptr_v6 (ctx, b, qname, qclass, qtype); - - bool include_a = false; - bool include_aaaa = false; - bool include_match = false; - bool include_ptr = false; - for (const char *p = qname; *p != '.' && *p != '\0'; ++p) - { - if (*p == 'a') - include_a = true; - else if (*p == 'q') - include_aaaa = true; - else if (*p == 'm') - include_match = true; - else if (*p == 'p') - include_ptr = true; - else if (*p == '6' && qtype == T_AAAA) - break; - } - if (include_match) - { - if (qtype == T_A) - include_aaaa = false; - else if (qtype == T_AAAA) - include_a = false; - } - - resolv_response_init (b, (struct resolv_response_flags) {}); - resolv_response_add_question (b, qname, qclass, qtype); - resolv_response_section (b, ns_s_an); - if (include_a) - { - char ipv4[4] = {192, 0, 2, 17}; - resolv_response_open_record (b, qname, qclass, T_A, 0); - resolv_response_add_data (b, &ipv4, sizeof (ipv4)); - resolv_response_close_record (b); - } - if (include_aaaa) - { - char ipv6[16] - = {0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; - resolv_response_open_record (b, qname, qclass, T_AAAA, 0); - resolv_response_add_data (b, &ipv6, sizeof (ipv6)); - resolv_response_close_record (b); - } - if (include_ptr) - { - resolv_response_open_record (b, qname, qclass, T_PTR, 0); - resolv_response_add_name (b, "ptr-target.example"); - resolv_response_close_record (b); - } -} - -/* Test that getaddrinfo is not influenced by RES_USE_INET6. */ -static void -test_gai (void) -{ - { - struct addrinfo hints = - { - .ai_family = AF_UNSPEC, - .ai_socktype = SOCK_STREAM, - .ai_protocol = IPPROTO_TCP, - }; - struct addrinfo *ai; - int ret = getaddrinfo ("qam.example", "80", &hints, &ai); - check_addrinfo ("getaddrinfo AF_UNSPEC qam.example", ai, ret, - "address: STREAM/TCP 192.0.2.17 80\n" - "address: STREAM/TCP 2001:db8::1 80\n"); - if (ret == 0) - freeaddrinfo (ai); - ret = getaddrinfo ("am.example", "80", &hints, &ai); - check_addrinfo ("getaddrinfo AF_UNSPEC am.example", ai, ret, - "address: STREAM/TCP 192.0.2.17 80\n"); - if (ret == 0) - freeaddrinfo (ai); - ret = getaddrinfo ("qa.example", "80", &hints, &ai); - /* Combined A/AAAA responses currently result in address - duplication. */ - check_addrinfo ("getaddrinfo AF_UNSPEC qa.example", ai, ret, - "address: STREAM/TCP 192.0.2.17 80\n" - "address: STREAM/TCP 192.0.2.17 80\n" - "address: STREAM/TCP 2001:db8::1 80\n" - "address: STREAM/TCP 2001:db8::1 80\n"); - if (ret == 0) - freeaddrinfo (ai); - } - { - struct addrinfo hints = - { - .ai_family = AF_INET, - .ai_socktype = SOCK_STREAM, - .ai_protocol = IPPROTO_TCP, - }; - struct addrinfo *ai; - int ret = getaddrinfo ("qam.example", "80", &hints, &ai); - check_addrinfo ("getaddrinfo AF_INET qam.example", ai, ret, - "address: STREAM/TCP 192.0.2.17 80\n"); - if (ret == 0) - freeaddrinfo (ai); - ret = getaddrinfo ("am.example", "80", &hints, &ai); - check_addrinfo ("getaddrinfo AF_INET am.example", ai, ret, - "address: STREAM/TCP 192.0.2.17 80\n"); - if (ret == 0) - freeaddrinfo (ai); - ret = getaddrinfo ("qa.example", "80", &hints, &ai); - check_addrinfo ("getaddrinfo AF_INET qa.example", ai, ret, - "address: STREAM/TCP 192.0.2.17 80\n"); - if (ret == 0) - freeaddrinfo (ai); - } - { - struct addrinfo hints = - { - .ai_family = AF_INET6, - .ai_socktype = SOCK_STREAM, - .ai_protocol = IPPROTO_TCP, - }; - struct addrinfo *ai; - int ret = getaddrinfo ("qa.example", "80", &hints, &ai); - check_addrinfo ("getaddrinfo (AF_INET6)", ai, ret, - "address: STREAM/TCP 2001:db8::1 80\n"); - if (ret == 0) - freeaddrinfo (ai); - ret = getaddrinfo ("am.example", "80", &hints, &ai); - check_addrinfo ("getaddrinfo AF_INET6 am.example", ai, ret, - "error: No address associated with hostname\n"); |
