mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
Extend --conf-dir to allow filtering on file suffixes.
This commit is contained in:
@@ -31,6 +31,10 @@ version 2.72
|
|||||||
advertisements for the prefix we're advertising. Thanks to
|
advertisements for the prefix we're advertising. Thanks to
|
||||||
Ilya Ponetaev for the patch.
|
Ilya Ponetaev for the patch.
|
||||||
|
|
||||||
|
Extend --conf-dir to allow filtering of files. So
|
||||||
|
--conf-dir=/etc/dnsmasq.d,\*.conf
|
||||||
|
will load all the files in /etc/dnsmasq.d which end in .conf
|
||||||
|
|
||||||
|
|
||||||
version 2.71
|
version 2.71
|
||||||
Subtle change to error handling to help DNSSEC validation
|
Subtle change to error handling to help DNSSEC validation
|
||||||
|
|||||||
@@ -640,3 +640,9 @@
|
|||||||
# Include another lot of configuration options.
|
# Include another lot of configuration options.
|
||||||
#conf-file=/etc/dnsmasq.more.conf
|
#conf-file=/etc/dnsmasq.more.conf
|
||||||
#conf-dir=/etc/dnsmasq.d
|
#conf-dir=/etc/dnsmasq.d
|
||||||
|
|
||||||
|
# Include all the files in a directory except those ending in .bak
|
||||||
|
#conf-dir=/etc/dnsmasq.d,.bak
|
||||||
|
|
||||||
|
# Include all files in a directory which end in .conf
|
||||||
|
#conf-dir=/etc/dnsmasq.d/*.conf
|
||||||
@@ -1725,12 +1725,16 @@ Specify a different configuration file. The conf-file option is also allowed in
|
|||||||
configuration files, to include multiple configuration files. A
|
configuration files, to include multiple configuration files. A
|
||||||
filename of "-" causes dnsmasq to read configuration from stdin.
|
filename of "-" causes dnsmasq to read configuration from stdin.
|
||||||
.TP
|
.TP
|
||||||
.B \-7, --conf-dir=<directory>[,<file-extension>......]
|
.B \-7, --conf-dir=<directory>[,<file-extension>......],
|
||||||
Read all the files in the given directory as configuration
|
Read all the files in the given directory as configuration
|
||||||
files. If extension(s) are given, any files which end in those
|
files. If extension(s) are given, any files which end in those
|
||||||
extensions are skipped. Any files whose names end in ~ or start with . or start and end
|
extensions are skipped. Any files whose names end in ~ or start with . or start and end
|
||||||
with # are always skipped. This flag may be given on the command
|
with # are always skipped. If the extension starts with * then only files
|
||||||
line or in a configuration file.
|
which have that extension are loaded. So
|
||||||
|
.B --conf-dir=/path/to/dir,*.conf
|
||||||
|
loads all files with the suffix .conf in /path/to/dir. This flag may be given on the command
|
||||||
|
line or in a configuration file. If giving it on the command line, be sure to
|
||||||
|
escape * characters.
|
||||||
.TP
|
.TP
|
||||||
.B --servers-file=<file>
|
.B --servers-file=<file>
|
||||||
A special case of
|
A special case of
|
||||||
|
|||||||
34
src/option.c
34
src/option.c
@@ -1465,7 +1465,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
struct list {
|
struct list {
|
||||||
char *suffix;
|
char *suffix;
|
||||||
struct list *next;
|
struct list *next;
|
||||||
} *ignore_suffix = NULL, *li;
|
} *ignore_suffix = NULL, *match_suffix = NULL, *li;
|
||||||
|
|
||||||
comma = split(arg);
|
comma = split(arg);
|
||||||
if (!(directory = opt_string_alloc(arg)))
|
if (!(directory = opt_string_alloc(arg)))
|
||||||
@@ -1475,10 +1475,20 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
{
|
{
|
||||||
comma = split(arg);
|
comma = split(arg);
|
||||||
li = opt_malloc(sizeof(struct list));
|
li = opt_malloc(sizeof(struct list));
|
||||||
li->next = ignore_suffix;
|
if (*arg == '*')
|
||||||
ignore_suffix = li;
|
{
|
||||||
/* Have to copy: buffer is overwritten */
|
li->next = match_suffix;
|
||||||
li->suffix = opt_string_alloc(arg);
|
match_suffix = li;
|
||||||
|
/* Have to copy: buffer is overwritten */
|
||||||
|
li->suffix = opt_string_alloc(arg+1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
li->next = ignore_suffix;
|
||||||
|
ignore_suffix = li;
|
||||||
|
/* Have to copy: buffer is overwritten */
|
||||||
|
li->suffix = opt_string_alloc(arg);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!(dir_stream = opendir(directory)))
|
if (!(dir_stream = opendir(directory)))
|
||||||
@@ -1496,6 +1506,20 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
ent->d_name[0] == '.')
|
ent->d_name[0] == '.')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (match_suffix)
|
||||||
|
{
|
||||||
|
for (li = match_suffix; li; li = li->next)
|
||||||
|
{
|
||||||
|
/* check for required suffices */
|
||||||
|
size_t ls = strlen(li->suffix);
|
||||||
|
if (len > ls &&
|
||||||
|
strcmp(li->suffix, &ent->d_name[len - ls]) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!li)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (li = ignore_suffix; li; li = li->next)
|
for (li = ignore_suffix; li; li = li->next)
|
||||||
{
|
{
|
||||||
/* check for proscribed suffices */
|
/* check for proscribed suffices */
|
||||||
|
|||||||
Reference in New Issue
Block a user