1
0

0010-Remove-the-NO_FORK-compile-time-option-and-support-f.patch 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. From 48d12f14c9c0fc8cf943b52774c3892517dd72d4 Mon Sep 17 00:00:00 2001
  2. From: Simon Kelley <simon@thekelleys.org.uk>
  3. Date: Fri, 2 Nov 2018 21:55:04 +0000
  4. Subject: [PATCH 10/32] Remove the NO_FORK compile-time option, and support for
  5. uclinux.
  6. In an era where everything has an MMU, this looks like
  7. an anachronism, and it adds to (Ok, multiplies!) the
  8. combinatorial explosion of compile-time options.
  9. Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
  10. ---
  11. CHANGELOG | 6 ++++++
  12. src/config.h | 21 ++-------------------
  13. src/dnsmasq.c | 14 --------------
  14. src/option.c | 4 +---
  15. 4 files changed, 9 insertions(+), 36 deletions(-)
  16. --- a/CHANGELOG
  17. +++ b/CHANGELOG
  18. @@ -11,6 +11,12 @@ version 2.81
  19. This fix passes cache entries back from the TCP child process to
  20. the main server process, and fixes the problem.
  21. + Remove the NO_FORK compile-time option, and support for uclinux.
  22. + In an era where everything has an MMU, this looks like
  23. + an anachronism, and it adds to (Ok, multiplies!) the
  24. + combinatorial explosion of compile-time options. Thanks to
  25. + Kevin Darbyshire-Bryant for the patch.
  26. +
  27. version 2.80
  28. Add support for RFC 4039 DHCP rapid commit. Thanks to Ashram Method
  29. --- a/src/config.h
  30. +++ b/src/config.h
  31. @@ -239,27 +239,13 @@ HAVE_SOCKADDR_SA_LEN
  32. defined if struct sockaddr has sa_len field (*BSD)
  33. */
  34. -/* Must precede __linux__ since uClinux defines __linux__ too. */
  35. -#if defined(__uClinux__)
  36. -#define HAVE_LINUX_NETWORK
  37. -#define HAVE_GETOPT_LONG
  38. -#undef HAVE_SOCKADDR_SA_LEN
  39. -/* Never use fork() on uClinux. Note that this is subtly different from the
  40. - --keep-in-foreground option, since it also suppresses forking new
  41. - processes for TCP connections and disables the call-a-script on leasechange
  42. - system. It's intended for use on MMU-less kernels. */
  43. -#define NO_FORK
  44. -
  45. -#elif defined(__UCLIBC__)
  46. +#if defined(__UCLIBC__)
  47. #define HAVE_LINUX_NETWORK
  48. #if defined(__UCLIBC_HAS_GNU_GETOPT__) || \
  49. ((__UCLIBC_MAJOR__==0) && (__UCLIBC_MINOR__==9) && (__UCLIBC_SUBLEVEL__<21))
  50. # define HAVE_GETOPT_LONG
  51. #endif
  52. #undef HAVE_SOCKADDR_SA_LEN
  53. -#if !defined(__ARCH_HAS_MMU__) && !defined(__UCLIBC_HAS_MMU__)
  54. -# define NO_FORK
  55. -#endif
  56. #if defined(__UCLIBC_HAS_IPV6__)
  57. # ifndef IPV6_V6ONLY
  58. # define IPV6_V6ONLY 26
  59. @@ -328,7 +314,7 @@ HAVE_SOCKADDR_SA_LEN
  60. #define HAVE_DHCP
  61. #endif
  62. -#if defined(NO_SCRIPT) || defined(NO_FORK)
  63. +#if defined(NO_SCRIPT)
  64. #undef HAVE_SCRIPT
  65. #undef HAVE_LUASCRIPT
  66. #endif
  67. @@ -372,9 +358,6 @@ static char *compile_opts =
  68. #ifdef HAVE_BROKEN_RTC
  69. "no-RTC "
  70. #endif
  71. -#ifdef NO_FORK
  72. -"no-MMU "
  73. -#endif
  74. #ifndef HAVE_DBUS
  75. "no-"
  76. #endif
  77. --- a/src/dnsmasq.c
  78. +++ b/src/dnsmasq.c
  79. @@ -485,7 +485,6 @@ int main (int argc, char **argv)
  80. if (chdir("/") != 0)
  81. die(_("cannot chdir to filesystem root: %s"), NULL, EC_MISC);
  82. -#ifndef NO_FORK
  83. if (!option_bool(OPT_NO_FORK))
  84. {
  85. pid_t pid;
  86. @@ -525,7 +524,6 @@ int main (int argc, char **argv)
  87. if (pid != 0)
  88. _exit(0);
  89. }
  90. -#endif
  91. /* write pidfile _after_ forking ! */
  92. if (daemon->runfile)
  93. @@ -1628,12 +1626,10 @@ static int set_dns_listeners(time_t now)
  94. }
  95. -#ifndef NO_FORK
  96. if (!option_bool(OPT_DEBUG))
  97. for (i = 0; i < MAX_PROCS; i++)
  98. if (daemon->tcp_pipes[i] != -1)
  99. poll_listen(daemon->tcp_pipes[i], POLLIN);
  100. -#endif
  101. return wait;
  102. }
  103. @@ -1643,9 +1639,7 @@ static void check_dns_listeners(time_t n
  104. struct serverfd *serverfdp;
  105. struct listener *listener;
  106. int i;
  107. -#ifndef NO_FORK
  108. int pipefd[2];
  109. -#endif
  110. for (serverfdp = daemon->sfds; serverfdp; serverfdp = serverfdp->next)
  111. if (poll_check(serverfdp->fd, POLLIN))
  112. @@ -1657,7 +1651,6 @@ static void check_dns_listeners(time_t n
  113. poll_check(daemon->randomsocks[i].fd, POLLIN))
  114. reply_query(daemon->randomsocks[i].fd, daemon->randomsocks[i].family, now);
  115. -#ifndef NO_FORK
  116. /* Races. The child process can die before we read all of the data from the
  117. pipe, or vice versa. Therefore send tcp_pids to zero when we wait() the
  118. process, and tcp_pipes to -1 and close the FD when we read the last
  119. @@ -1674,7 +1667,6 @@ static void check_dns_listeners(time_t n
  120. close(daemon->tcp_pipes[i]);
  121. daemon->tcp_pipes[i] = -1;
  122. }
  123. -#endif
  124. for (listener = daemon->listeners; listener; listener = listener->next)
  125. {
  126. @@ -1768,7 +1760,6 @@ static void check_dns_listeners(time_t n
  127. shutdown(confd, SHUT_RDWR);
  128. while (retry_send(close(confd)));
  129. }
  130. -#ifndef NO_FORK
  131. else if (!option_bool(OPT_DEBUG) && pipe(pipefd) == 0 && (p = fork()) != 0)
  132. {
  133. close(pipefd[1]); /* parent needs read pipe end. */
  134. @@ -1791,7 +1782,6 @@ static void check_dns_listeners(time_t n
  135. /* The child can use up to TCP_MAX_QUERIES ids, so skip that many. */
  136. daemon->log_id += TCP_MAX_QUERIES;
  137. }
  138. -#endif
  139. else
  140. {
  141. unsigned char *buff;
  142. @@ -1811,7 +1801,6 @@ static void check_dns_listeners(time_t n
  143. auth_dns = 0;
  144. }
  145. -#ifndef NO_FORK
  146. /* Arrange for SIGALRM after CHILD_LIFETIME seconds to
  147. terminate the process. */
  148. if (!option_bool(OPT_DEBUG))
  149. @@ -1820,7 +1809,6 @@ static void check_dns_listeners(time_t n
  150. close(pipefd[0]); /* close read end in child. */
  151. daemon->pipe_to_parent = pipefd[1];
  152. }
  153. -#endif
  154. /* start with no upstream connections. */
  155. for (s = daemon->servers; s; s = s->next)
  156. @@ -1846,13 +1834,11 @@ static void check_dns_listeners(time_t n
  157. shutdown(s->tcpfd, SHUT_RDWR);
  158. while (retry_send(close(s->tcpfd)));
  159. }
  160. -#ifndef NO_FORK
  161. if (!option_bool(OPT_DEBUG))
  162. {
  163. flush_log();
  164. _exit(0);
  165. }
  166. -#endif
  167. }
  168. }
  169. }
  170. --- a/src/option.c
  171. +++ b/src/option.c
  172. @@ -1828,9 +1828,7 @@ static int one_opt(int option, char *arg
  173. /* Sorry about the gross pre-processor abuse */
  174. case '6': /* --dhcp-script */
  175. case LOPT_LUASCRIPT: /* --dhcp-luascript */
  176. -# if defined(NO_FORK)
  177. - ret_err(_("cannot run scripts under uClinux"));
  178. -# elif !defined(HAVE_SCRIPT)
  179. +# if !defined(HAVE_SCRIPT)
  180. ret_err(_("recompile with HAVE_SCRIPT defined to enable lease-change scripts"));
  181. # else
  182. if (option == LOPT_LUASCRIPT)