From patchwork Tue Sep 5 16:05:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Stelmach?= X-Patchwork-Id: 810216 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-84194-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="kjgi/jUh"; 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 3xms6N2Wq3z9ryk for ; Wed, 6 Sep 2017 02:06:52 +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:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=ei51AYKVQqOcLtLhWzpLwpo4MUkSTMxvt0oO+vGX8DO dObI6+Fj8Tppzt64O1ke2cI0W16EOCz0kXL1fjEiEaCk90Jn0OnSMoxMvPJ0ctvH gIsJhGBCduba2773URqoiTP1M3daD8/L8a8EteUcZtNQ7IVUpZIGnwbQ76037f00 = 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:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; s=default; bh=ojimxtpv1GGVbbROBH5aKgT9Isg=; b=kjgi/jUhK0EgAK2mE yrGXd6xuBAblVhBaoGDQXtmJztf8iMpjW5hw6ozI1x2BUJBuvzTu+tCMFFArdZXX PbrJ49WaKjRRApgZAZiwYXrKtmEDewSYGxbeihPhxiBmQ91tpYF0FxiVvYYy61Ko hsBUqoxplaRk39liQaEet8ClqM= Received: (qmail 118266 invoked by alias); 5 Sep 2017 16:06:20 -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 118214 invoked by uid 89); 5 Sep 2017 16:06:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=t_a, T_A X-HELO: smtpo.poczta.interia.pl X-Interia-R: Interia X-Interia-R-IP: 89.64.33.181 X-Interia-R-Helo: From: =?utf-8?q?=C5=81ukasz_Stelmach?= To: libc-alpha@sourceware.org Cc: =?utf-8?q?=C5=81ukasz_Stelmach?= Subject: [RFC][PATCH 3/4][BZ 17083] NSS: Introduce gethostbyname5_r function Date: Tue, 5 Sep 2017 18:05:29 +0200 Message-Id: <20170905160530.19525-4-stlman@poczta.fm> In-Reply-To: <20170905160530.19525-1-stlman@poczta.fm> References: <20170905160530.19525-1-stlman@poczta.fm> MIME-Version: 1.0 X-Interia-Antivirus: OK X-IPL-POID: 4 X-IPL-SAS-SPAS: -0.6 X-IPL-SAS-UREP: 0 X-IPL-SAS-UREP-PRIV: 0 X-IPL-Envelope-To: stlman@poczta.fm Add af (address family) to the list of arguments of gethostbyname4_r function in files, dns, nis and nisplus module and rename the function to gethostbyname5_r. Pass the af value to the underlying parsing functions. Define gethostbyname4_r as a wrapper for the former passing af set to AF_UNSPEC. Signed-off-by: Ɓukasz Stelmach --- nis/Versions | 3 ++- nis/nss_nis/nis-hosts.c | 13 +++++++++++-- nis/nss_nisplus/nisplus-hosts.c | 13 +++++++++++-- nss/Versions | 1 + nss/nss_files/files-hosts.c | 13 +++++++++++-- resolv/Versions | 2 +- resolv/nss_dns/dns-host.c | 32 ++++++++++++++++++++++++++++++-- 7 files changed, 67 insertions(+), 10 deletions(-) diff --git a/nis/Versions b/nis/Versions index ef9a512417..537f0aa3c0 100644 --- a/nis/Versions +++ b/nis/Versions @@ -96,6 +96,7 @@ libnss_nis { _nss_nis_setnetgrent; _nss_nis_setprotoent; _nss_nis_setpwent; _nss_nis_setrpcent; _nss_nis_setservent; _nss_nis_setspent; _nss_nis_initgroups_dyn; _nss_nis_gethostbyname4_r; + _nss_nis_gethostbyname5_r; } } @@ -126,6 +127,6 @@ libnss_nisplus { _nss_nisplus_setnetent; _nss_nisplus_setnetgrent; _nss_nisplus_setprotoent; _nss_nisplus_setpwent; _nss_nisplus_setrpcent; _nss_nisplus_setservent; _nss_nisplus_setspent; _nss_nisplus_initgroups_dyn; - _nss_nisplus_gethostbyname4_r; + _nss_nisplus_gethostbyname4_r; _nss_nisplus_gethostbyname5_r; } } diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c index f64dbdaecb..3a156aa7ee 100644 --- a/nis/nss_nis/nis-hosts.c +++ b/nis/nss_nis/nis-hosts.c @@ -454,7 +454,7 @@ _nss_nis_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af, enum nss_status -_nss_nis_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, +_nss_nis_gethostbyname5_r (const char *name, int af, struct gaih_addrtuple **pat, char *buffer, size_t buflen, int *errnop, int *herrnop, int32_t *ttlp) { @@ -530,7 +530,7 @@ _nss_nis_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, buflen -= pad; struct hostent host; - int parse_res = parse_line (result, &host, data, buflen, errnop, AF_UNSPEC, + int parse_res = parse_line (result, &host, data, buflen, errnop, af, 0); if (__glibc_unlikely (parse_res < 1)) { @@ -565,3 +565,12 @@ _nss_nis_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, return NSS_STATUS_SUCCESS; } + +enum nss_status +_nss_nis_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, + char *buffer, size_t buflen, int *errnop, + int *herrnop, int32_t *ttlp) +{ + return _nss_nis_gethostbyname5_r (name, AF_UNSPEC, pat, buffer, buflen, + errnop, herrnop, ttlp); +} diff --git a/nis/nss_nisplus/nisplus-hosts.c b/nis/nss_nisplus/nisplus-hosts.c index 31dfd31fbd..d9c5d7a974 100644 --- a/nis/nss_nisplus/nisplus-hosts.c +++ b/nis/nss_nisplus/nisplus-hosts.c @@ -579,13 +579,13 @@ _nss_nisplus_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af, enum nss_status -_nss_nisplus_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, +_nss_nisplus_gethostbyname5_r (const char *name, int af, struct gaih_addrtuple **pat, char *buffer, size_t buflen, int *errnop, int *herrnop, int32_t *ttlp) { struct hostent host; - enum nss_status status = internal_gethostbyname2_r (name, AF_UNSPEC, &host, + enum nss_status status = internal_gethostbyname2_r (name, af, &host, buffer, buflen, errnop, herrnop, 0); if (__glibc_likely (status == NSS_STATUS_SUCCESS)) @@ -617,3 +617,12 @@ _nss_nisplus_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, return status; } + +enum nss_status +_nss_nisplus_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, + char *buffer, size_t buflen, int *errnop, + int *herrnop, int32_t *ttlp) +{ + return _nss_nisplus_gethostbyname5_r (name, AF_UNSPEC, pat, buffer, + buflen, errnop, herrnop, ttlp); +} diff --git a/nss/Versions b/nss/Versions index 50268ed9b5..72adf4c806 100644 --- a/nss/Versions +++ b/nss/Versions @@ -44,6 +44,7 @@ libnss_files { _nss_files_gethostbyname2_r; _nss_files_gethostbyname3_r; _nss_files_gethostbyname4_r; + _nss_files_gethostbyname5_r; _nss_files_gethostbyname_r; _nss_files_gethostent_r; diff --git a/nss/nss_files/files-hosts.c b/nss/nss_files/files-hosts.c index 28eb73fb2d..c6067cc641 100644 --- a/nss/nss_files/files-hosts.c +++ b/nss/nss_files/files-hosts.c @@ -404,7 +404,7 @@ _nss_files_gethostbyname2_r (const char *name, int af, struct hostent *result, } enum nss_status -_nss_files_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, +_nss_files_gethostbyname5_r (const char *name, int af, struct gaih_addrtuple **pat, char *buffer, size_t buflen, int *errnop, int *herrnop, int32_t *ttlp) { @@ -428,7 +428,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, &in6_zone_id); + herrnop, af, 0, &in6_zone_id); if (status != NSS_STATUS_SUCCESS) break; @@ -518,3 +518,12 @@ _nss_files_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, return status; } + +enum nss_status +_nss_files_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, + char *buffer, size_t buflen, int *errnop, + int *herrnop, int32_t *ttlp) +{ + return _nss_files_gethostbyname5_r (name, AF_UNSPEC, pat, buffer, buflen, + errnop, herrnop, ttlp); +} diff --git a/resolv/Versions b/resolv/Versions index b05778d965..2ae1048908 100644 --- a/resolv/Versions +++ b/resolv/Versions @@ -96,7 +96,7 @@ libnss_dns { _nss_dns_gethostbyname_r; _nss_dns_getnetbyaddr_r; _nss_dns_getnetbyname_r; _nss_dns_getcanonname_r; _nss_dns_gethostbyaddr2_r; - _nss_dns_gethostbyname4_r; + _nss_dns_gethostbyname4_r; _nss_dns_gethostbyname5_r; } } diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index 7cd54ab504..dddb8f4bef 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -308,7 +308,7 @@ _nss_dns_gethostbyname_r (const char *name, struct hostent *result, enum nss_status -_nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, +_nss_dns_gethostbyname5_r (const char *name, int af, struct gaih_addrtuple **pat, char *buffer, size_t buflen, int *errnop, int *herrnop, int32_t *ttlp) { @@ -344,10 +344,28 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, int nans2p = 0; int resplen2 = 0; int ans2p_malloced = 0; + int type; int olderr = errno; enum nss_status status; - int n = __res_context_search (ctx, name, C_IN, T_QUERY_A_AND_AAAA, + + switch (af) { + case AF_UNSPEC: + type = T_QUERY_A_AND_AAAA; + break; + case AF_INET: + type = T_A; + break; + case AF_INET6: + type = T_AAAA; + break; + default: + *herrnop = NO_DATA; + *errnop = EAFNOSUPPORT; + return NSS_STATUS_UNAVAIL; + } + + int n = __res_context_search (ctx, name, C_IN, type, host_buffer.buf->buf, 2048, &host_buffer.ptr, &ans2p, &nans2p, &resplen2, &ans2p_malloced); if (n >= 0) @@ -397,6 +415,16 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, } +enum nss_status +_nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, + char *buffer, size_t buflen, int *errnop, + int *herrnop, int32_t *ttlp) +{ + return _nss_dns_gethostbyname5_r (name, AF_UNSPEC, pat, buffer, buflen, + errnop, herrnop,ttlp); +} + + extern enum nss_status _nss_dns_gethostbyaddr2_r (const void *addr, socklen_t len, int af, struct hostent *result,