main: add option to print configuration

Add -p option to chronyd to print lines from the configuration as they
are parsed and exit. It can be used to verify the syntax and get the
whole configuration when it is split into multiple files.
This commit is contained in:
Miroslav Lichvar
2020-06-10 13:13:11 +02:00
parent d69ac07183
commit 1b82604f61
4 changed files with 34 additions and 3 deletions

12
conf.c
View File

@@ -85,6 +85,7 @@ static void parse_tempcomp(char *);
/* ================================================== */
/* Configuration variables */
static int print_config = 0;
static int restarted = 0;
static char *rtc_device;
static int acquisition_port = -1;
@@ -439,6 +440,14 @@ CNF_Finalise(void)
/* ================================================== */
void
CNF_EnablePrint(void)
{
print_config = 1;
}
/* ================================================== */
/* Read the configuration file */
void
CNF_ReadFile(const char *filename)
@@ -489,6 +498,9 @@ CNF_ParseLine(const char *filename, int number, char *line)
processed_command = command = line;
p = CPS_SplitWord(line);
if (print_config && strcasecmp(command, "include") && strcasecmp(command, "confdirs"))
printf("%s%s%s\n", command, p[0] != '\0' ? " " : "", p);
if (!strcasecmp(command, "acquisitionport")) {
parse_int(p, &acquisition_port);
} else if (!strcasecmp(command, "allow")) {