conf: allow wildcard patterns in include directive
Use glob() to match and read multiple configuration files with one include directive.
This commit is contained in:
parent
05183748a8
commit
c0867b58f5
3 changed files with 21 additions and 5 deletions
|
@ -1668,12 +1668,15 @@ hwclockfile /etc/adjtime
|
||||||
@c {{{ include
|
@c {{{ include
|
||||||
@node include directive
|
@node include directive
|
||||||
@subsection include
|
@subsection include
|
||||||
The @code{include} directive includes a specified configuration file.
|
The @code{include} directive includes a specified configuration file or
|
||||||
This is useful when maintaining configuration on multiple hosts to
|
multiple configuration files when a wildcard pattern is specified. This can be
|
||||||
keep the differences in a separate file.
|
useful when maintaining configuration on multiple hosts to keep the differences
|
||||||
|
in separate files.
|
||||||
|
|
||||||
|
An example of the command is
|
||||||
|
|
||||||
@example
|
@example
|
||||||
include @SYSCONFDIR@/chrony/local.conf
|
include @SYSCONFDIR@/chrony.d/*.conf
|
||||||
@end example
|
@end example
|
||||||
@c }}}
|
@c }}}
|
||||||
@c {{{ initstepslew
|
@c {{{ initstepslew
|
||||||
|
|
14
conf.c
14
conf.c
|
@ -1236,8 +1236,20 @@ parse_tempcomp(char *line)
|
||||||
static void
|
static void
|
||||||
parse_include(char *line)
|
parse_include(char *line)
|
||||||
{
|
{
|
||||||
|
glob_t gl;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
check_number_of_args(line, 1);
|
check_number_of_args(line, 1);
|
||||||
CNF_ReadFile(line);
|
|
||||||
|
if (glob(line, 0, NULL, &gl)) {
|
||||||
|
DEBUG_LOG(LOGF_Configure, "glob of %s failed", line);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < gl.gl_pathc; i++)
|
||||||
|
CNF_ReadFile(gl.gl_pathv[i]);
|
||||||
|
|
||||||
|
globfree(&gl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
#include <glob.h>
|
||||||
#if !defined(__FreeBSD__) && !defined(MACOSX)
|
#if !defined(__FreeBSD__) && !defined(MACOSX)
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue