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/11] Remove the NO_FORK compile-time option, and support for
7 In an era where everything has an MMU, this looks like
8 an anachronism, and it adds to (Ok, multiplies!) the
9 combinatorial explosion of compile-time options.
11 Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
14 src/config.h | 21 ++-------------------
15 src/dnsmasq.c | 14 --------------
17 4 files changed, 9 insertions(+), 36 deletions(-)
21 @@ -11,6 +11,12 @@ version 2.81
22 This fix passes cache entries back from the TCP child process to
23 the main server process, and fixes the problem.
25 + Remove the NO_FORK compile-time option, and support for uclinux.
26 + In an era where everything has an MMU, this looks like
27 + an anachronism, and it adds to (Ok, multiplies!) the
28 + combinatorial explosion of compile-time options. Thanks to
29 + Kevin Darbyshire-Bryant for the patch.
33 Add support for RFC 4039 DHCP rapid commit. Thanks to Ashram Method
36 @@ -239,27 +239,13 @@ HAVE_SOCKADDR_SA_LEN
37 defined if struct sockaddr has sa_len field (*BSD)
40 -/* Must precede __linux__ since uClinux defines __linux__ too. */
41 -#if defined(__uClinux__)
42 -#define HAVE_LINUX_NETWORK
43 -#define HAVE_GETOPT_LONG
44 -#undef HAVE_SOCKADDR_SA_LEN
45 -/* Never use fork() on uClinux. Note that this is subtly different from the
46 - --keep-in-foreground option, since it also suppresses forking new
47 - processes for TCP connections and disables the call-a-script on leasechange
48 - system. It's intended for use on MMU-less kernels. */
51 -#elif defined(__UCLIBC__)
52 +#if defined(__UCLIBC__)
53 #define HAVE_LINUX_NETWORK
54 #if defined(__UCLIBC_HAS_GNU_GETOPT__) || \
55 ((__UCLIBC_MAJOR__==0) && (__UCLIBC_MINOR__==9) && (__UCLIBC_SUBLEVEL__<21))
56 # define HAVE_GETOPT_LONG
58 #undef HAVE_SOCKADDR_SA_LEN
59 -#if !defined(__ARCH_HAS_MMU__) && !defined(__UCLIBC_HAS_MMU__)
62 #if defined(__UCLIBC_HAS_IPV6__)
64 # define IPV6_V6ONLY 26
65 @@ -328,7 +314,7 @@ HAVE_SOCKADDR_SA_LEN
69 -#if defined(NO_SCRIPT) || defined(NO_FORK)
70 +#if defined(NO_SCRIPT)
74 @@ -372,9 +358,6 @@ static char *compile_opts =
75 #ifdef HAVE_BROKEN_RTC
86 @@ -485,7 +485,6 @@ int main (int argc, char **argv)
88 die(_("cannot chdir to filesystem root: %s"), NULL, EC_MISC);
91 if (!option_bool(OPT_NO_FORK))
94 @@ -525,7 +524,6 @@ int main (int argc, char **argv)
100 /* write pidfile _after_ forking ! */
102 @@ -1628,12 +1626,10 @@ static int set_dns_listeners(time_t now)
107 if (!option_bool(OPT_DEBUG))
108 for (i = 0; i < MAX_PROCS; i++)
109 if (daemon->tcp_pipes[i] != -1)
110 poll_listen(daemon->tcp_pipes[i], POLLIN);
115 @@ -1643,9 +1639,7 @@ static void check_dns_listeners(time_t n
116 struct serverfd *serverfdp;
117 struct listener *listener;
123 for (serverfdp = daemon->sfds; serverfdp; serverfdp = serverfdp->next)
124 if (poll_check(serverfdp->fd, POLLIN))
125 @@ -1657,7 +1651,6 @@ static void check_dns_listeners(time_t n
126 poll_check(daemon->randomsocks[i].fd, POLLIN))
127 reply_query(daemon->randomsocks[i].fd, daemon->randomsocks[i].family, now);
130 /* Races. The child process can die before we read all of the data from the
131 pipe, or vice versa. Therefore send tcp_pids to zero when we wait() the
132 process, and tcp_pipes to -1 and close the FD when we read the last
133 @@ -1674,7 +1667,6 @@ static void check_dns_listeners(time_t n
134 close(daemon->tcp_pipes[i]);
135 daemon->tcp_pipes[i] = -1;
139 for (listener = daemon->listeners; listener; listener = listener->next)
141 @@ -1768,7 +1760,6 @@ static void check_dns_listeners(time_t n
142 shutdown(confd, SHUT_RDWR);
143 while (retry_send(close(confd)));
146 else if (!option_bool(OPT_DEBUG) && pipe(pipefd) == 0 && (p = fork()) != 0)
148 close(pipefd[1]); /* parent needs read pipe end. */
149 @@ -1791,7 +1782,6 @@ static void check_dns_listeners(time_t n
150 /* The child can use up to TCP_MAX_QUERIES ids, so skip that many. */
151 daemon->log_id += TCP_MAX_QUERIES;
157 @@ -1811,7 +1801,6 @@ static void check_dns_listeners(time_t n
162 /* Arrange for SIGALRM after CHILD_LIFETIME seconds to
163 terminate the process. */
164 if (!option_bool(OPT_DEBUG))
165 @@ -1820,7 +1809,6 @@ static void check_dns_listeners(time_t n
166 close(pipefd[0]); /* close read end in child. */
167 daemon->pipe_to_parent = pipefd[1];
171 /* start with no upstream connections. */
172 for (s = daemon->servers; s; s = s->next)
173 @@ -1846,13 +1834,11 @@ static void check_dns_listeners(time_t n
174 shutdown(s->tcpfd, SHUT_RDWR);
175 while (retry_send(close(s->tcpfd)));
178 if (!option_bool(OPT_DEBUG))
189 @@ -1828,9 +1828,7 @@ static int one_opt(int option, char *arg
190 /* Sorry about the gross pre-processor abuse */
191 case '6': /* --dhcp-script */
192 case LOPT_LUASCRIPT: /* --dhcp-luascript */
193 -# if defined(NO_FORK)
194 - ret_err(_("cannot run scripts under uClinux"));
195 -# elif !defined(HAVE_SCRIPT)
196 +# if !defined(HAVE_SCRIPT)
197 ret_err(_("recompile with HAVE_SCRIPT defined to enable lease-change scripts"));
199 if (option == LOPT_LUASCRIPT)