120-dnsmasq-compile-time-option-NO_ID.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. From f6bea86c78ba9efbd01da3dd2fb18764ec806290 Mon Sep 17 00:00:00 2001
  2. From: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>
  3. Date: Wed, 7 Sep 2016 09:35:07 +0100
  4. Subject: [PATCH] dnsmasq: compile time option NO_ID
  5. Some consider it good practice to obscure software version numbers to
  6. clients. Compiling with -DNO_ID removes the *.bind info structure.
  7. This includes: version, author, copyright, cachesize, cache insertions,
  8. evictions, misses & hits, auth & servers.
  9. Signed-off-by: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>
  10. ---
  11. src/cache.c | 2 ++
  12. src/config.h | 5 +++++
  13. src/dnsmasq.h | 4 ++++
  14. src/option.c | 8 ++++++--
  15. src/rfc1035.c | 3 ++-
  16. 5 files changed, 19 insertions(+), 3 deletions(-)
  17. --- a/src/cache.c
  18. +++ b/src/cache.c
  19. @@ -1290,6 +1290,7 @@ void cache_add_dhcp_entry(char *host_nam
  20. }
  21. #endif
  22. +#ifndef NO_ID
  23. int cache_make_stat(struct txt_record *t)
  24. {
  25. static char *buff = NULL;
  26. @@ -1385,6 +1386,7 @@ int cache_make_stat(struct txt_record *t
  27. *buff = len;
  28. return 1;
  29. }
  30. +#endif
  31. /* There can be names in the cache containing control chars, don't
  32. mess up logging or open security holes. */
  33. --- a/src/config.h
  34. +++ b/src/config.h
  35. @@ -120,6 +120,8 @@ HAVE_LOOP
  36. HAVE_INOTIFY
  37. use the Linux inotify facility to efficiently re-read configuration files.
  38. +NO_ID
  39. + Don't report *.bind CHAOS info to clients.
  40. NO_IPV6
  41. NO_TFTP
  42. NO_DHCP
  43. @@ -434,6 +436,9 @@ static char *compile_opts =
  44. "no-"
  45. #endif
  46. "DNSSEC "
  47. +#ifdef NO_ID
  48. +"no-ID "
  49. +#endif
  50. #ifndef HAVE_LOOP
  51. "no-"
  52. #endif
  53. --- a/src/dnsmasq.h
  54. +++ b/src/dnsmasq.h
  55. @@ -286,6 +286,7 @@ struct naptr {
  56. struct naptr *next;
  57. };
  58. +#ifndef NO_ID
  59. #define TXT_STAT_CACHESIZE 1
  60. #define TXT_STAT_INSERTS 2
  61. #define TXT_STAT_EVICTIONS 3
  62. @@ -293,6 +294,7 @@ struct naptr {
  63. #define TXT_STAT_HITS 5
  64. #define TXT_STAT_AUTH 6
  65. #define TXT_STAT_SERVERS 7
  66. +#endif
  67. struct txt_record {
  68. char *name;
  69. @@ -1078,7 +1080,9 @@ void cache_add_dhcp_entry(char *host_nam
  70. struct in_addr a_record_from_hosts(char *name, time_t now);
  71. void cache_unhash_dhcp(void);
  72. void dump_cache(time_t now);
  73. +#ifndef NO_ID
  74. int cache_make_stat(struct txt_record *t);
  75. +#endif
  76. char *cache_get_name(struct crec *crecp);
  77. char *cache_get_cname_target(struct crec *crecp);
  78. struct crec *cache_enumerate(int init);
  79. --- a/src/option.c
  80. +++ b/src/option.c
  81. @@ -657,7 +657,8 @@ static int atoi_check8(char *a, int *res
  82. return 1;
  83. }
  84. #endif
  85. -
  86. +
  87. +#ifndef NO_ID
  88. static void add_txt(char *name, char *txt, int stat)
  89. {
  90. struct txt_record *r = opt_malloc(sizeof(struct txt_record));
  91. @@ -670,13 +671,14 @@ static void add_txt(char *name, char *tx
  92. *(r->txt) = len;
  93. memcpy((r->txt)+1, txt, len);
  94. }
  95. -
  96. +
  97. r->stat = stat;
  98. r->name = opt_string_alloc(name);
  99. r->next = daemon->txt;
  100. daemon->txt = r;
  101. r->class = C_CHAOS;
  102. }
  103. +#endif
  104. static void do_usage(void)
  105. {
  106. @@ -4515,6 +4517,7 @@ void read_opts(int argc, char **argv, ch
  107. daemon->soa_expiry = SOA_EXPIRY;
  108. daemon->max_port = MAX_PORT;
  109. +#ifndef NO_ID
  110. add_txt("version.bind", "dnsmasq-" VERSION, 0 );
  111. add_txt("authors.bind", "Simon Kelley", 0);
  112. add_txt("copyright.bind", COPYRIGHT, 0);
  113. @@ -4527,6 +4530,7 @@ void read_opts(int argc, char **argv, ch
  114. add_txt("auth.bind", NULL, TXT_STAT_AUTH);
  115. #endif
  116. add_txt("servers.bind", NULL, TXT_STAT_SERVERS);
  117. +#endif
  118. while (1)
  119. {
  120. --- a/src/rfc1035.c
  121. +++ b/src/rfc1035.c
  122. @@ -1264,6 +1264,7 @@ size_t answer_request(struct dns_header
  123. unsigned long ttl = daemon->local_ttl;
  124. int ok = 1;
  125. log_query(F_CONFIG | F_RRNAME, name, NULL, "<TXT>");
  126. +#ifndef NO_ID
  127. /* Dynamically generate stat record */
  128. if (t->stat != 0)
  129. {
  130. @@ -1271,7 +1272,7 @@ size_t answer_request(struct dns_header
  131. if (!cache_make_stat(t))
  132. ok = 0;
  133. }
  134. -
  135. +#endif
  136. if (ok && add_resource_record(header, limit, &trunc, nameoffset, &ansp,
  137. ttl, NULL,
  138. T_TXT, t->class, "t", t->len, t->txt))