From patchwork Thu May 16 12:34:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1100543 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-102017-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="clfiOyfk"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 454W8B2Pcxz9s9T for ; Thu, 16 May 2019 22:34:34 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=cC0Hk96rLnfLru4i1ZXPOqeqHsmxw ZPEmlDa9tkceDB58n14N6YIivuvp/tzWuPWFUV8oKWYVkPd0BgC2WxZshvFuKyLj ILj5LWyCH3Nm5tJsxXoD5W2cZy1txkA3cRNGKN18Qrna0GwVwIYpyBD/RH/H9o9r QbtlcumEmv+k0E= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; s=default; bh=ySgJdtoy3Vadd+GH81b+R76TD1M=; b=clf iOyfkStGIL0vHGBhRCau+IWqVhBAQClzO+Kq5lU7Z/ibXkBeXAXrILKOpvQ6Hag2 BU/bI6s+7W+ofY4+UFQ7YVI16p9eVIGioXg2okUB3TmDwats0mittHB8va8RCToQ L9tGSdVfZB6Ny8dH0V5MED0fb5i2nLCozPfeBmp0= Received: (qmail 87254 invoked by alias); 16 May 2019 12:34:28 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 87246 invoked by uid 89); 16 May 2019 12:34:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=enlarge X-HELO: mx1.redhat.com From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH] nss_files: Remove RES_USE_INET6 from hosts processing Date: Thu, 16 May 2019 14:34:23 +0200 Message-ID: <87o942tw6o.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Since commit 3f8b44be0a658266adff5ece1e4bc3ce097a5dbe ("resolv: Remove support for RES_USE_INET6 and the inet6 option"), res_use_inet6 () always evaluates to false. 2019-05-16 Florian Weimer * nss/nss_files/files-hosts.c (EXTRA_ARGS, EXTRA_ARGS_DECL): Remove flags. (LINE_PARSER): Remove address mapping. (EXTRA_ARGS_VALUE): Remove flags argument. (gethostbyname3_multi): Likewise. Adjust call to internal_getent. (_nss_files_gethostbyname3_r): Adjust calls to internal_getent and gethostbyname3_multi. (_nss_files_gethostbyname_r): Always use AF_INET. Adjust call to _nss_files_gethostbyname3_r. (_nss_files_gethostbyname4_r): Adjust call to internal_getent. diff --git a/nss/nss_files/files-hosts.c b/nss/nss_files/files-hosts.c index 2ce0dc3b4c..da5967a87d 100644 --- a/nss/nss_files/files-hosts.c +++ b/nss/nss_files/files-hosts.c @@ -27,7 +27,6 @@ /* Get implementation for some internal functions. */ -#include "../resolv/mapv4v6addr.h" #include "../resolv/res_hconf.h" @@ -35,8 +34,8 @@ #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 @@ -61,12 +60,7 @@ LINE_PARSER af = af == AF_UNSPEC ? AF_INET : af; else { - if (af == AF_INET6 && (flags & AI_V4MAPPED) != 0 - && inet_pton (AF_INET, addr, entdata->host_addr) > 0) - map_v4v6_address ((char *) entdata->host_addr, - (char *) entdata->host_addr); - else if (af == AF_INET - && inet_pton (AF_INET6, addr, entdata->host_addr) > 0) + if (af == AF_INET && inet_pton (AF_INET6, addr, entdata->host_addr) > 0) { if (IN6_IS_ADDR_V4MAPPED (entdata->host_addr)) memcpy (entdata->host_addr, entdata->host_addr + 12, INADDRSZ); @@ -99,16 +93,13 @@ LINE_PARSER STRING_FIELD (result->h_name, isspace, 1); }) -#define EXTRA_ARGS_VALUE \ - , (res_use_inet6 () ? AF_INET6 : AF_INET), \ - (res_use_inet6 () ? AI_V4MAPPED : 0) +#define EXTRA_ARGS_VALUE , AF_INET #include "files-XXX.c" #undef EXTRA_ARGS_VALUE /* We only need to consider IPv4 mapped addresses if the input to the gethostbyaddr() function is an IPv6 address. */ -#define EXTRA_ARGS_VALUE \ - , af, (len == IN6ADDRSZ ? AI_V4MAPPED : 0) +#define EXTRA_ARGS_VALUE , af DB_LOOKUP (hostbyaddr, ,,, { if (result->h_length == (int) len @@ -126,7 +117,7 @@ DB_LOOKUP (hostbyaddr, ,,, static enum nss_status gethostbyname3_multi (FILE * stream, const char *name, int af, struct hostent *result, char *buffer, size_t buflen, - int *errnop, int *herrnop, int flags) + int *errnop, int *herrnop) { assert (af == AF_INET || af == AF_INET6); @@ -160,8 +151,7 @@ gethostbyname3_multi (FILE * stream, const char *name, int af, while (true) { status = internal_getent (stream, &tmp_result_buf, tmp_buffer.data, - tmp_buffer.length, errnop, herrnop, af, - flags); + tmp_buffer.length, errnop, herrnop, af); /* Enlarge the buffer if necessary. */ if (status == NSS_STATUS_TRYAGAIN && *herrnop == NETDB_INTERNAL && *errnop == ERANGE) @@ -345,12 +335,8 @@ _nss_files_gethostbyname3_r (const char *name, int af, struct hostent *result, if (status == NSS_STATUS_SUCCESS) { - /* XXX Is using _res to determine whether we want to convert IPv4 - addresses to IPv6 addresses really the right thing to do? */ - int flags = (res_use_inet6 () ? AI_V4MAPPED : 0); - while ((status = internal_getent (stream, result, buffer, buflen, errnop, - herrnop, af, flags)) + herrnop, af)) == NSS_STATUS_SUCCESS) { LOOKUP_NAME_CASE (h_name, h_aliases) @@ -359,7 +345,7 @@ _nss_files_gethostbyname3_r (const char *name, int af, struct hostent *result, if (status == NSS_STATUS_SUCCESS && _res_hconf.flags & HCONF_FLAG_MULTI) status = gethostbyname3_multi - (stream, name, af, result, buffer, buflen, errnop, herrnop, flags); + (stream, name, af, result, buffer, buflen, errnop, herrnop); internal_endent (&stream); } @@ -375,9 +361,7 @@ _nss_files_gethostbyname_r (const char *name, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *herrnop) { - int af = (res_use_inet6 () ? AF_INET6 : AF_INET); - - return _nss_files_gethostbyname3_r (name, af, result, buffer, buflen, + return _nss_files_gethostbyname3_r (name, AF_INET, result, buffer, buflen, errnop, herrnop, NULL, NULL); } @@ -414,7 +398,7 @@ _nss_files_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, struct hostent result; status = internal_getent (stream, &result, buffer, buflen, errnop, - herrnop, AF_UNSPEC, 0); + herrnop, AF_UNSPEC); if (status != NSS_STATUS_SUCCESS) break;