0006-Fix-spurious-AD-flags-in-some-DNS-replies-from-local.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. From 6f7812d97bc8f87004c0a5069c6c94c64af78106 Mon Sep 17 00:00:00 2001
  2. From: Simon Kelley <simon@thekelleys.org.uk>
  3. Date: Tue, 23 Oct 2018 23:54:44 +0100
  4. Subject: [PATCH 06/32] Fix spurious AD flags in some DNS replies from local
  5. config.
  6. Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
  7. ---
  8. src/rfc1035.c | 42 ++++++++++++++++++++++++------------------
  9. 1 file changed, 24 insertions(+), 18 deletions(-)
  10. --- a/src/rfc1035.c
  11. +++ b/src/rfc1035.c
  12. @@ -1330,7 +1330,7 @@ size_t answer_request(struct dns_header
  13. {
  14. if (t->class == qclass && hostname_isequal(name, t->name))
  15. {
  16. - ans = 1;
  17. + ans = 1, sec_data = 0;
  18. if (!dryrun)
  19. {
  20. unsigned long ttl = daemon->local_ttl;
  21. @@ -1370,7 +1370,7 @@ size_t answer_request(struct dns_header
  22. addr.addr.rcode.rcode = NOTIMP;
  23. log_query(F_CONFIG | F_RCODE, name, &addr, NULL);
  24. }
  25. - ans = 1;
  26. + ans = 1, sec_data = 0;
  27. }
  28. }
  29. }
  30. @@ -1725,7 +1725,7 @@ size_t answer_request(struct dns_header
  31. }
  32. else if (is_name_synthetic(flag, name, &addr))
  33. {
  34. - ans = 1;
  35. + ans = 1, sec_data = 0;
  36. if (!dryrun)
  37. {
  38. log_query(F_FORWARD | F_CONFIG | flag, name, &addr, NULL);
  39. @@ -1763,25 +1763,27 @@ size_t answer_request(struct dns_header
  40. for (rec = daemon->mxnames; rec; rec = rec->next)
  41. if (!rec->issrv && hostname_isequal(name, rec->name))
  42. {
  43. - ans = found = 1;
  44. - if (!dryrun)
  45. - {
  46. - int offset;
  47. - log_query(F_CONFIG | F_RRNAME, name, NULL, "<MX>");
  48. - if (add_resource_record(header, limit, &trunc, nameoffset, &ansp, daemon->local_ttl,
  49. - &offset, T_MX, C_IN, "sd", rec->weight, rec->target))
  50. - {
  51. - anscount++;
  52. - if (rec->target)
  53. - rec->offset = offset;
  54. - }
  55. - }
  56. + ans = found = 1;
  57. + sec_data = 0;
  58. + if (!dryrun)
  59. + {
  60. + int offset;
  61. + log_query(F_CONFIG | F_RRNAME, name, NULL, "<MX>");
  62. + if (add_resource_record(header, limit, &trunc, nameoffset, &ansp, daemon->local_ttl,
  63. + &offset, T_MX, C_IN, "sd", rec->weight, rec->target))
  64. + {
  65. + anscount++;
  66. + if (rec->target)
  67. + rec->offset = offset;
  68. + }
  69. + }
  70. }
  71. if (!found && (option_bool(OPT_SELFMX) || option_bool(OPT_LOCALMX)) &&
  72. cache_find_by_name(NULL, name, now, F_HOSTS | F_DHCP | F_NO_RR))
  73. {
  74. ans = 1;
  75. + sec_data = 0;
  76. if (!dryrun)
  77. {
  78. log_query(F_CONFIG | F_RRNAME, name, NULL, "<MX>");
  79. @@ -1802,6 +1804,7 @@ size_t answer_request(struct dns_header
  80. if (rec->issrv && hostname_isequal(name, rec->name))
  81. {
  82. found = ans = 1;
  83. + sec_data = 0;
  84. if (!dryrun)
  85. {
  86. int offset;
  87. @@ -1838,6 +1841,7 @@ size_t answer_request(struct dns_header
  88. if (!found && option_bool(OPT_FILTER) && (qtype == T_SRV || (qtype == T_ANY && strchr(name, '_'))))
  89. {
  90. ans = 1;
  91. + sec_data = 0;
  92. if (!dryrun)
  93. log_query(F_CONFIG | F_NEG, name, NULL, NULL);
  94. }
  95. @@ -1850,6 +1854,7 @@ size_t answer_request(struct dns_header
  96. if (hostname_isequal(name, na->name))
  97. {
  98. ans = 1;
  99. + sec_data = 0;
  100. if (!dryrun)
  101. {
  102. log_query(F_CONFIG | F_RRNAME, name, NULL, "<NAPTR>");
  103. @@ -1862,11 +1867,12 @@ size_t answer_request(struct dns_header
  104. }
  105. if (qtype == T_MAILB)
  106. - ans = 1, nxdomain = 1;
  107. + ans = 1, nxdomain = 1, sec_data = 0;
  108. if (qtype == T_SOA && option_bool(OPT_FILTER))
  109. {
  110. - ans = 1;
  111. + ans = 1;
  112. + sec_data = 0;
  113. if (!dryrun)
  114. log_query(F_CONFIG | F_NEG, name, &addr, NULL);
  115. }