f57669
commit 6b142b3a1d007d7e6f50c26710de7177bc4aca74
f57669
Author: Andreas Schwab <schwab@suse.de>
f57669
Date:   Mon Jun 8 15:21:18 2015 +0200
f57669
f57669
    Record TTL also for DNS PTR queries (bug 18513)
f57669
    
f57669
    This allows nscd to manage proper TTL for GETHOSTBYADDR[v6] requests.
f57669
f57669
2015-06-22  Andreas Schwab  <schwab@suse.de>
f57669
f57669
	[BZ #18513]
f57669
	* resolv/nss_dns/dns-host.c (getanswer_r): Record TTL also for
f57669
	PTR queries.
f57669
f57669
Index: glibc-2.17-c758a686/resolv/nss_dns/dns-host.c
f57669
===================================================================
f57669
--- glibc-2.17-c758a686.orig/resolv/nss_dns/dns-host.c
f57669
+++ glibc-2.17-c758a686/resolv/nss_dns/dns-host.c
f57669
@@ -800,6 +800,10 @@ getanswer_r (const querybuf *answer, int
f57669
 
f57669
       if (qtype == T_PTR && type == T_CNAME)
f57669
 	{
f57669
+	  /* A CNAME could also have a TTL entry.  */
f57669
+	  if (ttlp != NULL && ttl < *ttlp)
f57669
+	      *ttlp = ttl;
f57669
+
f57669
 	  n = dn_expand (answer->buf, end_of_message, cp, tbuf, sizeof tbuf);
f57669
 	  if (__builtin_expect (n < 0 || res_dnok (tbuf) == 0, 0))
f57669
 	    {
f57669
@@ -863,6 +867,8 @@ getanswer_r (const querybuf *answer, int
f57669
 	      ++had_error;
f57669
 	      break;
f57669
 	    }
f57669
+	  if (ttlp != NULL && ttl < *ttlp)
f57669
+	      *ttlp = ttl;
f57669
 #if MULTI_PTRS_ARE_ALIASES
f57669
 	  cp += n;
f57669
 	  if (haveanswer == 0)