[PATCH] Record TTL also for DNS PTR queries
Andreas Schwab
schwab@suse.de
Wed Jun 10 10:01:00 GMT 2015
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;
--
2.4.3
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
More information about the Libc-alpha
mailing list