mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
Remove the NO_FORK compile-time option, and support for uclinux.
In an era where everything has an MMU, this looks like an anachronism, and it adds to (Ok, multiplies!) the combinatorial explosion of compile-time options.
This commit is contained in:
@@ -11,6 +11,12 @@ version 2.81
|
|||||||
This fix passes cache entries back from the TCP child process to
|
This fix passes cache entries back from the TCP child process to
|
||||||
the main server process, and fixes the problem.
|
the main server process, and fixes the problem.
|
||||||
|
|
||||||
|
Remove the NO_FORK compile-time option, and support for uclinux.
|
||||||
|
In an era where everything has an MMU, this looks like
|
||||||
|
an anachronism, and it adds to (Ok, multiplies!) the
|
||||||
|
combinatorial explosion of compile-time options. Thanks to
|
||||||
|
Kevin Darbyshire-Bryant for the patch.
|
||||||
|
|
||||||
|
|
||||||
version 2.80
|
version 2.80
|
||||||
Add support for RFC 4039 DHCP rapid commit. Thanks to Ashram Method
|
Add support for RFC 4039 DHCP rapid commit. Thanks to Ashram Method
|
||||||
|
|||||||
21
src/config.h
21
src/config.h
@@ -239,27 +239,13 @@ HAVE_SOCKADDR_SA_LEN
|
|||||||
defined if struct sockaddr has sa_len field (*BSD)
|
defined if struct sockaddr has sa_len field (*BSD)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Must precede __linux__ since uClinux defines __linux__ too. */
|
#if defined(__UCLIBC__)
|
||||||
#if defined(__uClinux__)
|
|
||||||
#define HAVE_LINUX_NETWORK
|
|
||||||
#define HAVE_GETOPT_LONG
|
|
||||||
#undef HAVE_SOCKADDR_SA_LEN
|
|
||||||
/* Never use fork() on uClinux. Note that this is subtly different from the
|
|
||||||
--keep-in-foreground option, since it also suppresses forking new
|
|
||||||
processes for TCP connections and disables the call-a-script on leasechange
|
|
||||||
system. It's intended for use on MMU-less kernels. */
|
|
||||||
#define NO_FORK
|
|
||||||
|
|
||||||
#elif defined(__UCLIBC__)
|
|
||||||
#define HAVE_LINUX_NETWORK
|
#define HAVE_LINUX_NETWORK
|
||||||
#if defined(__UCLIBC_HAS_GNU_GETOPT__) || \
|
#if defined(__UCLIBC_HAS_GNU_GETOPT__) || \
|
||||||
((__UCLIBC_MAJOR__==0) && (__UCLIBC_MINOR__==9) && (__UCLIBC_SUBLEVEL__<21))
|
((__UCLIBC_MAJOR__==0) && (__UCLIBC_MINOR__==9) && (__UCLIBC_SUBLEVEL__<21))
|
||||||
# define HAVE_GETOPT_LONG
|
# define HAVE_GETOPT_LONG
|
||||||
#endif
|
#endif
|
||||||
#undef HAVE_SOCKADDR_SA_LEN
|
#undef HAVE_SOCKADDR_SA_LEN
|
||||||
#if !defined(__ARCH_HAS_MMU__) && !defined(__UCLIBC_HAS_MMU__)
|
|
||||||
# define NO_FORK
|
|
||||||
#endif
|
|
||||||
#if defined(__UCLIBC_HAS_IPV6__)
|
#if defined(__UCLIBC_HAS_IPV6__)
|
||||||
# ifndef IPV6_V6ONLY
|
# ifndef IPV6_V6ONLY
|
||||||
# define IPV6_V6ONLY 26
|
# define IPV6_V6ONLY 26
|
||||||
@@ -328,7 +314,7 @@ HAVE_SOCKADDR_SA_LEN
|
|||||||
#define HAVE_DHCP
|
#define HAVE_DHCP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(NO_SCRIPT) || defined(NO_FORK)
|
#if defined(NO_SCRIPT)
|
||||||
#undef HAVE_SCRIPT
|
#undef HAVE_SCRIPT
|
||||||
#undef HAVE_LUASCRIPT
|
#undef HAVE_LUASCRIPT
|
||||||
#endif
|
#endif
|
||||||
@@ -372,9 +358,6 @@ static char *compile_opts =
|
|||||||
#ifdef HAVE_BROKEN_RTC
|
#ifdef HAVE_BROKEN_RTC
|
||||||
"no-RTC "
|
"no-RTC "
|
||||||
#endif
|
#endif
|
||||||
#ifdef NO_FORK
|
|
||||||
"no-MMU "
|
|
||||||
#endif
|
|
||||||
#ifndef HAVE_DBUS
|
#ifndef HAVE_DBUS
|
||||||
"no-"
|
"no-"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -485,7 +485,6 @@ int main (int argc, char **argv)
|
|||||||
if (chdir("/") != 0)
|
if (chdir("/") != 0)
|
||||||
die(_("cannot chdir to filesystem root: %s"), NULL, EC_MISC);
|
die(_("cannot chdir to filesystem root: %s"), NULL, EC_MISC);
|
||||||
|
|
||||||
#ifndef NO_FORK
|
|
||||||
if (!option_bool(OPT_NO_FORK))
|
if (!option_bool(OPT_NO_FORK))
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
@@ -525,7 +524,6 @@ int main (int argc, char **argv)
|
|||||||
if (pid != 0)
|
if (pid != 0)
|
||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* write pidfile _after_ forking ! */
|
/* write pidfile _after_ forking ! */
|
||||||
if (daemon->runfile)
|
if (daemon->runfile)
|
||||||
@@ -1628,12 +1626,10 @@ static int set_dns_listeners(time_t now)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_FORK
|
|
||||||
if (!option_bool(OPT_DEBUG))
|
if (!option_bool(OPT_DEBUG))
|
||||||
for (i = 0; i < MAX_PROCS; i++)
|
for (i = 0; i < MAX_PROCS; i++)
|
||||||
if (daemon->tcp_pipes[i] != -1)
|
if (daemon->tcp_pipes[i] != -1)
|
||||||
poll_listen(daemon->tcp_pipes[i], POLLIN);
|
poll_listen(daemon->tcp_pipes[i], POLLIN);
|
||||||
#endif
|
|
||||||
|
|
||||||
return wait;
|
return wait;
|
||||||
}
|
}
|
||||||
@@ -1643,9 +1639,7 @@ static void check_dns_listeners(time_t now)
|
|||||||
struct serverfd *serverfdp;
|
struct serverfd *serverfdp;
|
||||||
struct listener *listener;
|
struct listener *listener;
|
||||||
int i;
|
int i;
|
||||||
#ifndef NO_FORK
|
|
||||||
int pipefd[2];
|
int pipefd[2];
|
||||||
#endif
|
|
||||||
|
|
||||||
for (serverfdp = daemon->sfds; serverfdp; serverfdp = serverfdp->next)
|
for (serverfdp = daemon->sfds; serverfdp; serverfdp = serverfdp->next)
|
||||||
if (poll_check(serverfdp->fd, POLLIN))
|
if (poll_check(serverfdp->fd, POLLIN))
|
||||||
@@ -1657,7 +1651,6 @@ static void check_dns_listeners(time_t now)
|
|||||||
poll_check(daemon->randomsocks[i].fd, POLLIN))
|
poll_check(daemon->randomsocks[i].fd, POLLIN))
|
||||||
reply_query(daemon->randomsocks[i].fd, daemon->randomsocks[i].family, now);
|
reply_query(daemon->randomsocks[i].fd, daemon->randomsocks[i].family, now);
|
||||||
|
|
||||||
#ifndef NO_FORK
|
|
||||||
/* Races. The child process can die before we read all of the data from the
|
/* Races. The child process can die before we read all of the data from the
|
||||||
pipe, or vice versa. Therefore send tcp_pids to zero when we wait() the
|
pipe, or vice versa. Therefore send tcp_pids to zero when we wait() the
|
||||||
process, and tcp_pipes to -1 and close the FD when we read the last
|
process, and tcp_pipes to -1 and close the FD when we read the last
|
||||||
@@ -1674,7 +1667,6 @@ static void check_dns_listeners(time_t now)
|
|||||||
close(daemon->tcp_pipes[i]);
|
close(daemon->tcp_pipes[i]);
|
||||||
daemon->tcp_pipes[i] = -1;
|
daemon->tcp_pipes[i] = -1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
for (listener = daemon->listeners; listener; listener = listener->next)
|
for (listener = daemon->listeners; listener; listener = listener->next)
|
||||||
{
|
{
|
||||||
@@ -1768,7 +1760,6 @@ static void check_dns_listeners(time_t now)
|
|||||||
shutdown(confd, SHUT_RDWR);
|
shutdown(confd, SHUT_RDWR);
|
||||||
while (retry_send(close(confd)));
|
while (retry_send(close(confd)));
|
||||||
}
|
}
|
||||||
#ifndef NO_FORK
|
|
||||||
else if (!option_bool(OPT_DEBUG) && pipe(pipefd) == 0 && (p = fork()) != 0)
|
else if (!option_bool(OPT_DEBUG) && pipe(pipefd) == 0 && (p = fork()) != 0)
|
||||||
{
|
{
|
||||||
close(pipefd[1]); /* parent needs read pipe end. */
|
close(pipefd[1]); /* parent needs read pipe end. */
|
||||||
@@ -1791,7 +1782,6 @@ static void check_dns_listeners(time_t now)
|
|||||||
/* The child can use up to TCP_MAX_QUERIES ids, so skip that many. */
|
/* The child can use up to TCP_MAX_QUERIES ids, so skip that many. */
|
||||||
daemon->log_id += TCP_MAX_QUERIES;
|
daemon->log_id += TCP_MAX_QUERIES;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned char *buff;
|
unsigned char *buff;
|
||||||
@@ -1811,7 +1801,6 @@ static void check_dns_listeners(time_t now)
|
|||||||
auth_dns = 0;
|
auth_dns = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_FORK
|
|
||||||
/* Arrange for SIGALRM after CHILD_LIFETIME seconds to
|
/* Arrange for SIGALRM after CHILD_LIFETIME seconds to
|
||||||
terminate the process. */
|
terminate the process. */
|
||||||
if (!option_bool(OPT_DEBUG))
|
if (!option_bool(OPT_DEBUG))
|
||||||
@@ -1820,7 +1809,6 @@ static void check_dns_listeners(time_t now)
|
|||||||
close(pipefd[0]); /* close read end in child. */
|
close(pipefd[0]); /* close read end in child. */
|
||||||
daemon->pipe_to_parent = pipefd[1];
|
daemon->pipe_to_parent = pipefd[1];
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* start with no upstream connections. */
|
/* start with no upstream connections. */
|
||||||
for (s = daemon->servers; s; s = s->next)
|
for (s = daemon->servers; s; s = s->next)
|
||||||
@@ -1846,13 +1834,11 @@ static void check_dns_listeners(time_t now)
|
|||||||
shutdown(s->tcpfd, SHUT_RDWR);
|
shutdown(s->tcpfd, SHUT_RDWR);
|
||||||
while (retry_send(close(s->tcpfd)));
|
while (retry_send(close(s->tcpfd)));
|
||||||
}
|
}
|
||||||
#ifndef NO_FORK
|
|
||||||
if (!option_bool(OPT_DEBUG))
|
if (!option_bool(OPT_DEBUG))
|
||||||
{
|
{
|
||||||
flush_log();
|
flush_log();
|
||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1828,9 +1828,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
/* Sorry about the gross pre-processor abuse */
|
/* Sorry about the gross pre-processor abuse */
|
||||||
case '6': /* --dhcp-script */
|
case '6': /* --dhcp-script */
|
||||||
case LOPT_LUASCRIPT: /* --dhcp-luascript */
|
case LOPT_LUASCRIPT: /* --dhcp-luascript */
|
||||||
# if defined(NO_FORK)
|
# if !defined(HAVE_SCRIPT)
|
||||||
ret_err(_("cannot run scripts under uClinux"));
|
|
||||||
# elif !defined(HAVE_SCRIPT)
|
|
||||||
ret_err(_("recompile with HAVE_SCRIPT defined to enable lease-change scripts"));
|
ret_err(_("recompile with HAVE_SCRIPT defined to enable lease-change scripts"));
|
||||||
# else
|
# else
|
||||||
if (option == LOPT_LUASCRIPT)
|
if (option == LOPT_LUASCRIPT)
|
||||||
|
|||||||
Reference in New Issue
Block a user