From patchwork Thu Jul 15 09:10:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 44369 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0BD083AAAC39 for ; Thu, 15 Jul 2021 09:31:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0BD083AAAC39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1626341464; bh=xqcIIeDuurZpoPxquvq2egBtb8VPGYmADjJ7LNkqP/I=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=tOUzYa54PRPEyQuM6sUrD+d56uvXqcuYZY76Oo5yzPBmkuKjgcxH31l6oEjlyFTs4 3SLV1ddHxa4xmoV/7upZanLHkkIl8fG052I4P/j6Kg5ZvLG4JkJ9OBFfbq50rLMZgJ 4OTPuAj63it3zSsW95my76J0ayzi0H04M4z85acY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id CE5233AA9C1A for ; Thu, 15 Jul 2021 09:11:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CE5233AA9C1A Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-563-GErDZBgjPPKk3KiVkLGCLA-1; Thu, 15 Jul 2021 05:11:02 -0400 X-MC-Unique: GErDZBgjPPKk3KiVkLGCLA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5CB54100B3AF for ; Thu, 15 Jul 2021 09:11:01 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-112-73.phx2.redhat.com [10.3.112.73]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1EC56100EBAD for ; Thu, 15 Jul 2021 09:10:59 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 23/24] resolv: Move nss_dns into libc In-Reply-To: References: X-From-Line: d25e5c2df38fdd7d65578602ddf21deeb2933dee Mon Sep 17 00:00:00 2001 Message-Id: Date: Thu, 15 Jul 2021 11:10:57 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" No abilist updates are needed because the symbols were GLIBC_PRIVATE. Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell --- include/nss_dns.h | 36 ++++++++++++++++++++++++++ resolv/Makefile | 15 +++-------- resolv/Versions | 21 ++++++++------- resolv/nss_dns/dns-canon.c | 4 +-- resolv/nss_dns/dns-host.c | 50 +++++++++++++++++------------------- resolv/nss_dns/dns-network.c | 13 +++++----- 6 files changed, 82 insertions(+), 57 deletions(-) create mode 100644 include/nss_dns.h diff --git a/include/nss_dns.h b/include/nss_dns.h new file mode 100644 index 0000000000..63b5853870 --- /dev/null +++ b/include/nss_dns.h @@ -0,0 +1,36 @@ +/* Internal routines for nss_dns. + Copyright (C) 2021 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 + . */ + +#ifndef _NSS_DNS_H +#define _NSS_DNS_H + +#include + +NSS_DECLARE_MODULE_FUNCTIONS (dns) + +libc_hidden_proto (_nss_dns_getcanonname_r) +libc_hidden_proto (_nss_dns_gethostbyname3_r) +libc_hidden_proto (_nss_dns_gethostbyname2_r) +libc_hidden_proto (_nss_dns_gethostbyname_r) +libc_hidden_proto (_nss_dns_gethostbyname4_r) +libc_hidden_proto (_nss_dns_gethostbyaddr2_r) +libc_hidden_proto (_nss_dns_gethostbyaddr_r) +libc_hidden_proto (_nss_dns_getnetbyname_r) +libc_hidden_proto (_nss_dns_getnetbyaddr_r) + +#endif diff --git a/resolv/Makefile b/resolv/Makefile index 4ba58dfa96..dd0a98c74f 100644 --- a/resolv/Makefile +++ b/resolv/Makefile @@ -31,6 +31,9 @@ routines := \ dn_comp \ dn_expand \ dn_skipname \ + dns-canon \ + dns-host \ + dns-network \ herror \ inet_addr \ inet_ntop \ @@ -175,18 +178,6 @@ libanl-shared-only-routines += libanl-compat subdir-dirs = nss_dns vpath %.c nss_dns -libnss_dns-routines := \ - dns-canon \ - dns-host \ - dns-network \ - # libnss_dns-routines - -libnss_dns-inhibit-o = $(filter-out .os,$(object-suffixes)) -ifeq ($(build-static-nss),yes) -routines += $(libnss_dns-routines) $(libresolv-routines) -static-only-routines += $(libnss_dns-routines) $(libresolv-routines) -endif - ifeq ($(run-built-tests),yes) ifneq (no,$(PERL)) tests-special += $(objpfx)mtrace-tst-leaks.out $(objpfx)mtrace-tst-leaks2.out \ diff --git a/resolv/Versions b/resolv/Versions index 05679d42c1..6c7694e089 100644 --- a/resolv/Versions +++ b/resolv/Versions @@ -123,6 +123,15 @@ libc { __resolv_context_get_preinit; __resolv_context_put; __resp; + _nss_dns_getcanonname_r; + _nss_dns_gethostbyaddr2_r; + _nss_dns_gethostbyaddr_r; + _nss_dns_gethostbyname2_r; + _nss_dns_gethostbyname3_r; + _nss_dns_gethostbyname4_r; + _nss_dns_gethostbyname_r; + _nss_dns_getnetbyaddr_r; + _nss_dns_getnetbyname_r; } } @@ -214,15 +223,9 @@ libresolv { libnss_dns { GLIBC_PRIVATE { - _nss_dns_getcanonname_r; - _nss_dns_gethostbyaddr2_r; - _nss_dns_gethostbyaddr_r; - _nss_dns_gethostbyname2_r; - _nss_dns_gethostbyname3_r; - _nss_dns_gethostbyname4_r; - _nss_dns_gethostbyname_r; - _nss_dns_getnetbyaddr_r; - _nss_dns_getnetbyname_r; + # Keep a version node (with a synthesized local: * directive) so that + # __bss_* symbols are hidden on targets that need it. + __libnss_dns_version_placeholder; } } diff --git a/resolv/nss_dns/dns-canon.c b/resolv/nss_dns/dns-canon.c index c5718ce3ab..c892170abd 100644 --- a/resolv/nss_dns/dns-canon.c +++ b/resolv/nss_dns/dns-canon.c @@ -25,8 +25,7 @@ #include #include #include - -NSS_DECLARE_MODULE_FUNCTIONS (dns) +#include #if PACKETSZ > 65536 # define MAXPACKET PACKETSZ @@ -185,3 +184,4 @@ _nss_dns_getcanonname_r (const char *name, char *buffer, size_t buflen, __resolv_context_put (ctx); return status; } +libc_hidden_def (_nss_dns_getcanonname_r) diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index d6a69a602a..7248ade18d 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -82,6 +82,7 @@ #include "nsswitch.h" #include +#include #include #include @@ -90,8 +91,6 @@ #include #include -NSS_DECLARE_MODULE_FUNCTIONS (dns) - #define RESOLVSORT #if PACKETSZ > 65536 @@ -169,6 +168,7 @@ _nss_dns_gethostbyname3_r (const char *name, int af, struct hostent *result, __resolv_context_put (ctx); return status; } +libc_hidden_def (_nss_dns_gethostbyname3_r) static enum nss_status gethostbyname3_context (struct resolv_context *ctx, @@ -283,7 +283,7 @@ gethostbyname3_context (struct resolv_context *ctx, static enum nss_status check_name (const char *name, int *h_errnop) { - if (res_hnok (name)) + if (__libc_res_hnok (name)) return NSS_STATUS_SUCCESS; *h_errnop = HOST_NOT_FOUND; return NSS_STATUS_NOTFOUND; @@ -300,7 +300,7 @@ _nss_dns_gethostbyname2_r (const char *name, int af, struct hostent *result, return _nss_dns_gethostbyname3_r (name, af, result, buffer, buflen, errnop, h_errnop, NULL, NULL); } - +libc_hidden_def (_nss_dns_gethostbyname2_r) enum nss_status _nss_dns_gethostbyname_r (const char *name, struct hostent *result, @@ -327,7 +327,7 @@ _nss_dns_gethostbyname_r (const char *name, struct hostent *result, __resolv_context_put (ctx); return status; } - +libc_hidden_def (_nss_dns_gethostbyname_r) enum nss_status _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, @@ -419,15 +419,7 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, __resolv_context_put (ctx); return status; } - - -extern enum nss_status _nss_dns_gethostbyaddr2_r (const void *addr, - socklen_t len, int af, - struct hostent *result, - char *buffer, size_t buflen, - int *errnop, int *h_errnop, - int32_t *ttlp); -hidden_proto (_nss_dns_gethostbyaddr2_r) +libc_hidden_def (_nss_dns_gethostbyname4_r) enum nss_status _nss_dns_gethostbyaddr2_r (const void *addr, socklen_t len, int af, @@ -568,7 +560,7 @@ _nss_dns_gethostbyaddr2_r (const void *addr, socklen_t len, int af, __resolv_context_put (ctx); return NSS_STATUS_SUCCESS; } -hidden_def (_nss_dns_gethostbyaddr2_r) +libc_hidden_def (_nss_dns_gethostbyaddr2_r) enum nss_status @@ -579,6 +571,7 @@ _nss_dns_gethostbyaddr_r (const void *addr, socklen_t len, int af, return _nss_dns_gethostbyaddr2_r (addr, len, af, result, buffer, buflen, errnop, h_errnop, NULL); } +libc_hidden_def (_nss_dns_gethostbyaddr_r) static void addrsort (struct resolv_context *ctx, char **ap, int num) @@ -672,10 +665,10 @@ getanswer_r (struct resolv_context *ctx, { case T_A: case T_AAAA: - name_ok = res_hnok; + name_ok = __libc_res_hnok; break; case T_PTR: - name_ok = res_dnok; + name_ok = __libc_res_dnok; break; default: *errnop = ENOENT; @@ -810,7 +803,8 @@ getanswer_r (struct resolv_context *ctx, if (ap >= &host_data->aliases[MAX_NR_ALIASES - 1]) continue; - n = dn_expand (answer->buf, end_of_message, cp, tbuf, sizeof tbuf); + n = __libc_dn_expand (answer->buf, end_of_message, cp, + tbuf, sizeof tbuf); if (__glibc_unlikely (n < 0 || (*name_ok) (tbuf) == 0)) { ++had_error; @@ -848,8 +842,9 @@ getanswer_r (struct resolv_context *ctx, if (ttlp != NULL && ttl < *ttlp) *ttlp = ttl; - n = dn_expand (answer->buf, end_of_message, cp, tbuf, sizeof tbuf); - if (__glibc_unlikely (n < 0 || res_dnok (tbuf) == 0)) + n = __libc_dn_expand (answer->buf, end_of_message, cp, + tbuf, sizeof tbuf); + if (__glibc_unlikely (n < 0 || __libc_res_dnok (tbuf) == 0)) { ++had_error; continue; @@ -881,7 +876,7 @@ getanswer_r (struct resolv_context *ctx, switch (type) { case T_PTR: - if (__glibc_unlikely (strcasecmp (tname, bp) != 0)) + if (__glibc_unlikely (__strcasecmp (tname, bp) != 0)) { cp += n; continue; /* XXX - had_error++ ? */ @@ -897,7 +892,7 @@ getanswer_r (struct resolv_context *ctx, n = -1; } - if (__glibc_unlikely (n < 0 || res_hnok (bp) == 0)) + if (__glibc_unlikely (n < 0 || __libc_res_hnok (bp) == 0)) { ++had_error; break; @@ -911,7 +906,7 @@ getanswer_r (struct resolv_context *ctx, return NSS_STATUS_SUCCESS; case T_A: case T_AAAA: - if (__glibc_unlikely (strcasecmp (result->h_name, bp) != 0)) + if (__glibc_unlikely (__strcasecmp (result->h_name, bp) != 0)) { cp += n; continue; /* XXX - had_error++ ? */ @@ -1060,7 +1055,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, *h_errnop = NO_RECOVERY; return NSS_STATUS_UNAVAIL; } - if (__glibc_unlikely (res_hnok (buffer) == 0)) + if (__glibc_unlikely (__libc_res_hnok (buffer) == 0)) { errno = EBADMSG; *errnop = EBADMSG; @@ -1093,7 +1088,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, n = -1; } - if (__glibc_unlikely (n < 0 || res_hnok (buffer) == 0)) + if (__glibc_unlikely (n < 0 || __libc_res_hnok (buffer) == 0)) { ++had_error; continue; @@ -1142,8 +1137,9 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, if (ttlp != NULL && ttl < *ttlp) *ttlp = ttl; - n = dn_expand (answer->buf, end_of_message, cp, tbuf, sizeof tbuf); - if (__glibc_unlikely (n < 0 || res_hnok (tbuf) == 0)) + n = __libc_dn_expand (answer->buf, end_of_message, cp, + tbuf, sizeof tbuf); + if (__glibc_unlikely (n < 0 || __libc_res_hnok (tbuf) == 0)) { ++had_error; continue; diff --git a/resolv/nss_dns/dns-network.c b/resolv/nss_dns/dns-network.c index 801313caec..74b78959c2 100644 --- a/resolv/nss_dns/dns-network.c +++ b/resolv/nss_dns/dns-network.c @@ -67,11 +67,10 @@ #include "nsswitch.h" #include #include +#include #include #include -NSS_DECLARE_MODULE_FUNCTIONS (dns) - /* Maximum number of aliases we allow. */ #define MAX_NR_ALIASES 48 @@ -152,7 +151,7 @@ _nss_dns_getnetbyname_r (const char *name, struct netent *result, __resolv_context_put (ctx); return status; } - +libc_hidden_def (_nss_dns_getnetbyname_r) enum nss_status _nss_dns_getnetbyaddr_r (uint32_t net, int type, struct netent *result, @@ -246,7 +245,7 @@ _nss_dns_getnetbyaddr_r (uint32_t net, int type, struct netent *result, __resolv_context_put (ctx); return status; } - +libc_hidden_def (_nss_dns_getnetbyaddr_r) static enum nss_status getanswer_r (const querybuf *answer, int anslen, struct netent *result, @@ -347,7 +346,7 @@ getanswer_r (const querybuf *answer, int anslen, struct netent *result, n = -1; } - if (n < 0 || res_dnok (bp) == 0) + if (n < 0 || __libc_res_dnok (bp) == 0) break; cp += n; @@ -381,7 +380,7 @@ getanswer_r (const querybuf *answer, int anslen, struct netent *result, n = -1; } - if (n < 0 || !res_hnok (bp)) + if (n < 0 || !__libc_res_hnok (bp)) { /* XXX What does this mean? The original form from bind returns NULL. Incrementing cp has no effect in any case. @@ -469,7 +468,7 @@ getanswer_r (const querybuf *answer, int anslen, struct netent *result, /* If we are out of digits now, there are two cases: 1. We are done with digits and now see "in-addr.arpa". 2. This is not the droid we are looking for. */ - if (!isdigit (*p) && !strcasecmp (p, "in-addr.arpa")) + if (!isdigit (*p) && !__strcasecmp (p, "in-addr.arpa")) { result->n_net = val; return NSS_STATUS_SUCCESS;