0004-Don-t-forward-.bind-.server-queries-upstream.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. From cf5984367bc6a949e3803a576512c5a7bc48ebab Mon Sep 17 00:00:00 2001
  2. From: Vladislav Grishenko <[email protected]>
  3. Date: Thu, 18 Oct 2018 04:55:21 +0500
  4. Subject: [PATCH 04/11] Don't forward *.bind/*.server queries upstream
  5. Chaos .bind and .server (RFC4892) zones are local, therefore
  6. don't forward queries upstream to avoid mixing with supported
  7. locally and false replies with NO_ID enabled.
  8. Signed-off-by: Kevin Darbyshire-Bryant <[email protected]>
  9. ---
  10. src/rfc1035.c | 15 ++++++++++++++-
  11. 1 file changed, 14 insertions(+), 1 deletion(-)
  12. --- a/src/rfc1035.c
  13. +++ b/src/rfc1035.c
  14. @@ -1276,7 +1276,7 @@ size_t answer_request(struct dns_header
  15. int q, ans, anscount = 0, addncount = 0;
  16. int dryrun = 0;
  17. struct crec *crecp;
  18. - int nxdomain = 0, auth = 1, trunc = 0, sec_data = 1;
  19. + int nxdomain = 0, notimp = 0, auth = 1, trunc = 0, sec_data = 1;
  20. struct mx_srv_record *rec;
  21. size_t len;
  22. @@ -1355,6 +1355,17 @@ size_t answer_request(struct dns_header
  23. }
  24. }
  25. + if (qclass == C_CHAOS)
  26. + {
  27. + /* don't forward *.bind and *.server chaos queries */
  28. + if (hostname_issubdomain("bind", name) || hostname_issubdomain("server", name))
  29. + {
  30. + if (!ans)
  31. + notimp = 1, auth = 0;
  32. + ans = 1;
  33. + }
  34. + }
  35. +
  36. if (qclass == C_IN)
  37. {
  38. struct txt_record *t;
  39. @@ -1903,6 +1914,8 @@ size_t answer_request(struct dns_header
  40. if (nxdomain)
  41. SET_RCODE(header, NXDOMAIN);
  42. + else if (notimp)
  43. + SET_RCODE(header, NOTIMP);
  44. else
  45. SET_RCODE(header, NOERROR); /* no error */
  46. header->ancount = htons(anscount);