From patchwork Wed Jun 10 09:25:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 7094 Received: (qmail 17089 invoked by alias); 10 Jun 2015 09:25:10 -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 17080 invoked by uid 89); 10 Jun 2015 09:25:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx2.suse.de From: Andreas Schwab To: libc-alpha@sourceware.org Subject: [PATCH] Record TTL also for DNS PTR queries X-Yow: Where's my SOCIAL WORKER? Date: Wed, 10 Jun 2015 11:25:03 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 This allows nscd to manage proper TTL for GETHOSTBYADDR[v6] requests. Andreas. [BZ #18513] * resolv/nss_dns/dns-host.c (getanswer_r): Record TTL also for PTR queries. --- resolv/nss_dns/dns-host.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index d8c5579..357ac04 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -800,6 +800,10 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, if (qtype == T_PTR && type == T_CNAME) { + /* A CNAME could also have a TTL entry. */ + 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)) { @@ -863,6 +867,8 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, ++had_error; break; } + if (ttlp != NULL && ttl < *ttlp) + *ttlp = ttl; /* bind would put multiple PTR records as aliases, but we don't do that. */ result->h_name = bp;