Make --conf-file without filename just inhibit reading the default.

This is now consistent with the behaviour of --resolv-file.
This commit is contained in:
Simon Kelley committed 2026-11-30 17:04:33 +00:00
1 parent cc32bce779
commit 5ec80aa6c8
2 files changed
+15 -18

No files matched your search

+3 -3
View File
@@ -2318,9 +2318,9 @@ Run in a mode where the TFTP server uses ONLY the well-known port (69) for its e
of the TFTP transfer. This allows TFTP to work when there in NAT is the path between client and server. Note that of the TFTP transfer. This allows TFTP to work when there in NAT is the path between client and server. Note that
this is not strictly compliant with the RFCs specifying the TFTP protocol: use at your own risk. this is not strictly compliant with the RFCs specifying the TFTP protocol: use at your own risk.
.TP .TP
.B \-C, --conf-file=<file> .B \-C, --conf-file[=<file>]
Specify a configuration file. The presence of this option stops dnsmasq from reading the default configuration Specify a configuration file. The presence of this option (even without a filename) stops dnsmasq from
file (normally /etc/dnsmasq.conf). Multiple files may be specified by repeating the option reading the default configuration file (normally /etc/dnsmasq.conf). Multiple files may be specified by repeating the option
either on the command line or in configuration files. A either on the command line or in configuration files. A
filename of "-" causes dnsmasq to read configuration from stdin. filename of "-" causes dnsmasq to read configuration from stdin.
.TP .TP
+12 -15
View File
@@ -424,7 +424,7 @@ static struct {
{ 'b', OPT_BOGUSPRIV, NULL, gettext_noop("Fake reverse lookups for RFC1918 private address ranges."), NULL }, { '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 }, { '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)."), "$" }, { 'c', ARG_ONE, "<integer>", gettext_noop("Specify the size of the cache in entries (defaults to %s)."), "$" },
{ 'C', ARG_DUP, "<path>", gettext_noop("Specify configuration file (defaults to %s)."), CONFFILE }, { 'C', ARG_DUP, "[<path>]", gettext_noop("Specify configuration file (defaults to %s)."), CONFFILE },
{ 'd', OPT_DEBUG, NULL, gettext_noop("Do NOT fork into the background: run in debug mode."), NULL }, { '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 }, { '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 }, { 'e', OPT_SELFMX, NULL, gettext_noop("Return self-pointing MX records for local hosts."), NULL },
@@ -5985,8 +5985,8 @@ void read_opts(int argc, char **argv, char *compile_opts)
{ {
size_t argbuf_size = 300; size_t argbuf_size = 300;
char *argbuf = safe_malloc(argbuf_size); char *argbuf = safe_malloc(argbuf_size);
int option, testmode = 0; int option, testmode = 0, conf_read = 0;
char *arg, *conffile = NULL; char *arg;
opterr = 0; opterr = 0;
@@ -6095,13 +6095,15 @@ void read_opts(int argc, char **argv, char *compile_opts)
} }
else if (option == 'C') else if (option == 'C')
{ {
if (!conffile) char *conffile = opt_string_alloc(arg);
conffile = opt_string_alloc(arg);
else /* Inhibit /etc/dnsmasq.conf even if no file given */
conf_read = 1;
if (conffile)
{ {
char *extra = opt_string_alloc(arg); one_file(conffile, 0);
one_file(extra, 0); free(conffile);
free(extra);
} }
} }
else else
@@ -6117,12 +6119,7 @@ void read_opts(int argc, char **argv, char *compile_opts)
free(argbuf); free(argbuf);
if (conffile) if (!conf_read)
{
one_file(conffile, 0);
free(conffile);
}
else
one_file(CONFFILE, LOPT_CONF_OPT); one_file(CONFFILE, LOPT_CONF_OPT);
/* Add TXT records if wanted */ /* Add TXT records if wanted */