1f556a
Backport the support/ changes from this commit, to avoid future
1f556a
conflicts:
1f556a
1f556a
commit 446997ff1433d33452b81dfa9e626b8dccf101a4
1f556a
Author: Florian Weimer <fweimer@redhat.com>
1f556a
Date:   Wed Oct 30 17:26:58 2019 +0100
1f556a
1f556a
    resolv: Implement trust-ad option for /etc/resolv.conf [BZ #20358]
1f556a
    
1f556a
    This introduces a concept of trusted name servers, for which the
1f556a
    AD bit is passed through to applications.  For untrusted name
1f556a
    servers (the default), the AD bit in responses are cleared, to
1f556a
    provide a safe default.
1f556a
    
1f556a
    This approach is very similar to the one suggested by Pavel Šimerda
1f556a
    in <https://bugzilla.redhat.com/show_bug.cgi?id=1164339#c15>.
1f556a
    
1f556a
    The DNS test framework in support/ is enhanced with support for
1f556a
    setting the AD bit in responses.
1f556a
    
1f556a
    Tested on x86_64-linux-gnu.
1f556a
    
1f556a
    Change-Id: Ibfe0f7c73ea221c35979842c5c3b6ed486495ccc
1f556a
1f556a
diff --git a/support/resolv_test.c b/support/resolv_test.c
1f556a
index 3f2a09f36f445878..28af227cb5ed901c 100644
1f556a
--- a/support/resolv_test.c
1f556a
+++ b/support/resolv_test.c
1f556a
@@ -182,6 +182,8 @@ resolv_response_init (struct resolv_response_builder *b,
1f556a
   if (flags.tc)
1f556a
     b->buffer[2] |= 0x02;
1f556a
   b->buffer[3] = 0x80 | flags.rcode; /* Always set RA.  */
1f556a
+  if (flags.ad)
1f556a
+    b->buffer[3] |= 0x20;
1f556a
 
1f556a
   /* Fill in the initial section count values.  */
1f556a
   b->buffer[4] = flags.qdcount >> 8;
1f556a
diff --git a/support/resolv_test.h b/support/resolv_test.h
1f556a
index 4c2e6c1b417f5fcd..be736aead40cd0cc 100644
1f556a
--- a/support/resolv_test.h
1f556a
+++ b/support/resolv_test.h
1f556a
@@ -134,6 +134,9 @@ struct resolv_response_flags
1f556a
   /* If true, the TC (truncation) flag will be set.  */
1f556a
   bool tc;
1f556a
 
1f556a
+  /* If true, the AD (authenticated data) flag will be set.  */
1f556a
+  bool ad;
1f556a
+
1f556a
   /* Initial section count values.  Can be used to artificially
1f556a
      increase the counts, for malformed packet testing.*/
1f556a
   unsigned short qdcount;