mirror of
https://gitlab.com/chrony/chrony.git
synced 2026-01-21 21:30:19 -05:00
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:
12
conf.c
12
conf.c
@@ -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")) {
|
||||
|
||||
Reference in New Issue
Block a user