Changeset View
Changeset View
Standalone View
Standalone View
files/Make-it-stateless.patch
- This file was added.
| From c667e5778b2023e196f439e39b245cc60c18caf3 Mon Sep 17 00:00:00 2001 | |||||
| From: Fabio Forni <livingsilver94.solus@redaril.me> | |||||
| Date: Tue, 11 Aug 2020 15:43:29 +0200 | |||||
| Subject: [PATCH] Make it stateless | |||||
| --- | |||||
| src/config.h | 8 ++++++++ | |||||
| src/option.c | 16 ++++++++++++++-- | |||||
| 2 files changed, 22 insertions(+), 2 deletions(-) | |||||
| diff --git a/src/config.h b/src/config.h | |||||
| index 7d08f7d..607e5e6 100644 | |||||
| --- a/src/config.h | |||||
| +++ b/src/config.h | |||||
| @@ -153,6 +153,12 @@ RESOLVFILE | |||||
| the default locations of these files are determined below, but may be overridden | |||||
| in a build command line using COPTS. | |||||
| +DEFAULTCONFFILE | |||||
| + define a fallback config file path in case CONFFILE does not exist | |||||
| + or is not readable. This default config file will make dnsmasq die | |||||
| + if, in turn, it is not readable. | |||||
| + This options is suitable for so-called stateless installations. | |||||
| + | |||||
| */ | |||||
| /* Defining this builds a binary which handles time differently and works better on a system without a | |||||
| @@ -226,6 +232,8 @@ RESOLVFILE | |||||
| # endif | |||||
| #endif | |||||
| +#define DEFAULTCONFFILE "/usr/share/defaults/dnsmasq/dnsmasq.conf" | |||||
| + | |||||
| /* platform dependent options: these are determined automatically below | |||||
| HAVE_LINUX_NETWORK | |||||
| diff --git a/src/option.c b/src/option.c | |||||
| index 1f698da..ba26911 100644 | |||||
| --- a/src/option.c | |||||
| +++ b/src/option.c | |||||
| @@ -360,7 +360,11 @@ static struct { | |||||
| { 'b', OPT_BOGUSPRIV, NULL, gettext_noop("Fake reverse lookups for RFC1918 private address ranges."), NULL }, | |||||
| { 'B', ARG_DUP, "<ipaddr>", gettext_noop("Treat ipaddr as NXDOMAIN (defeats Verisign wildcard)."), NULL }, | |||||
| { 'c', ARG_ONE, "<integer>", gettext_noop("Specify the size of the cache in entries (defaults to %s)."), "$" }, | |||||
| + #ifdef DEFAULTCONFFILE | |||||
| + { 'C', ARG_DUP, "<path>", gettext_noop("Specify config file (defaults to %s, then "DEFAULTCONFFILE")."), CONFFILE }, | |||||
| + #else | |||||
| { 'C', ARG_DUP, "<path>", gettext_noop("Specify configuration file (defaults to %s)."), CONFFILE }, | |||||
| + #endif | |||||
| { 'd', OPT_DEBUG, NULL, gettext_noop("Do NOT fork into the background: run in debug mode."), NULL }, | |||||
| { 'D', OPT_NODOTS_LOCAL, NULL, gettext_noop("Do NOT forward queries with no domain part."), NULL }, | |||||
| { 'e', OPT_SELFMX, NULL, gettext_noop("Return self-pointing MX records for local hosts."), NULL }, | |||||
| @@ -5121,8 +5125,16 @@ void read_opts(int argc, char **argv, char *compile_opts) | |||||
| one_file(conffile, 0); | |||||
| free(conffile); | |||||
| } | |||||
| - else | |||||
| - one_file(CONFFILE, '7'); | |||||
| + else | |||||
| + { | |||||
| + one_file(CONFFILE, '7'); | |||||
| + #ifdef DEFAULTCONFFILE | |||||
| + if (errno == ENOENT) | |||||
| + { | |||||
| + one_file(DEFAULTCONFFILE, 0); | |||||
| + } | |||||
| + #endif | |||||
| + } | |||||
| /* port might not be known when the address is parsed - fill in here */ | |||||
| if (daemon->servers) | |||||
| -- | |||||
| 2.27.0 | |||||
Copyright © 2015-2021 Solus Project. The Solus logo is Copyright © 2016-2021 Solus Project. All Rights Reserved.