986cee
diff -up openssh-5.2p1/dns.c.rh205842 openssh-5.2p1/dns.c
986cee
--- openssh-5.2p1/dns.c.rh205842	2009-07-27 16:25:28.000000000 +0200
986cee
+++ openssh-5.2p1/dns.c	2009-07-27 16:40:59.000000000 +0200
986cee
@@ -176,6 +176,7 @@ verify_host_key_dns(const char *hostname
986cee
 {
986cee
 	u_int counter;
986cee
 	int result;
986cee
+	unsigned int rrset_flags = 0;
986cee
 	struct rrsetinfo *fingerprints = NULL;
986cee
 
986cee
 	u_int8_t hostkey_algorithm;
986cee
@@ -199,8 +200,19 @@ verify_host_key_dns(const char *hostname
986cee
 		return -1;
986cee
 	}
986cee
 
986cee
+	/*
986cee
+	 * Original getrrsetbyname function, found on OpenBSD for example,
986cee
+	 * doesn't accept any flag and prerequisite for obtaining AD bit in
986cee
+	 * DNS response is set by "options edns0" in resolv.conf.
986cee
+	 *
986cee
+	 * Our version is more clever and use RRSET_FORCE_EDNS0 flag.
986cee
+	 */
986cee
+#ifndef HAVE_GETRRSETBYNAME
986cee
+	rrset_flags |= RRSET_FORCE_EDNS0;
986cee
+#endif
986cee
 	result = getrrsetbyname(hostname, DNS_RDATACLASS_IN,
986cee
-	    DNS_RDATATYPE_SSHFP, 0, &fingerprints);
986cee
+	    DNS_RDATATYPE_SSHFP, rrset_flags, &fingerprints);
986cee
+
986cee
 	if (result) {
986cee
 		verbose("DNS lookup error: %s", dns_result_totext(result));
986cee
 		return -1;
986cee
diff -up openssh-5.2p1/openbsd-compat/getrrsetbyname.c.rh205842 openssh-5.2p1/openbsd-compat/getrrsetbyname.c
986cee
--- openssh-5.2p1/openbsd-compat/getrrsetbyname.c.rh205842	2009-07-27 16:22:23.000000000 +0200
986cee
+++ openssh-5.2p1/openbsd-compat/getrrsetbyname.c	2009-07-27 16:41:55.000000000 +0200
986cee
@@ -209,8 +209,8 @@ getrrsetbyname(const char *hostname, uns
986cee
 		goto fail;
986cee
 	}
986cee
 
986cee
-	/* don't allow flags yet, unimplemented */
986cee
-	if (flags) {
986cee
+	/* Allow RRSET_FORCE_EDNS0 flag only. */
986cee
+	if ((flags & !RRSET_FORCE_EDNS0) != 0) {
986cee
 		result = ERRSET_INVAL;
986cee
 		goto fail;
986cee
 	}
986cee
@@ -226,9 +226,9 @@ getrrsetbyname(const char *hostname, uns
986cee
 #endif /* DEBUG */
986cee
 
986cee
 #ifdef RES_USE_DNSSEC
986cee
-	/* turn on DNSSEC if EDNS0 is configured */
986cee
-	if (_resp->options & RES_USE_EDNS0)
986cee
-		_resp->options |= RES_USE_DNSSEC;
986cee
+	/* turn on DNSSEC if required  */
986cee
+	if (flags & RRSET_FORCE_EDNS0)
986cee
+		_resp->options |= (RES_USE_EDNS0|RES_USE_DNSSEC);
986cee
 #endif /* RES_USE_DNSEC */
986cee
 
986cee
 	/* make query */
986cee
diff -up openssh-5.2p1/openbsd-compat/getrrsetbyname.h.rh205842 openssh-5.2p1/openbsd-compat/getrrsetbyname.h
986cee
--- openssh-5.2p1/openbsd-compat/getrrsetbyname.h.rh205842	2009-07-27 16:35:02.000000000 +0200
986cee
+++ openssh-5.2p1/openbsd-compat/getrrsetbyname.h	2009-07-27 16:36:09.000000000 +0200
986cee
@@ -72,6 +72,9 @@
986cee
 #ifndef RRSET_VALIDATED
986cee
 # define RRSET_VALIDATED	1
986cee
 #endif
986cee
+#ifndef RRSET_FORCE_EDNS0
986cee
+# define RRSET_FORCE_EDNS0	0x0001
986cee
+#endif
986cee
 
986cee
 /*
986cee
  * Return codes for getrrsetbyname()