/* ================================================== */
/* Configuration variables */
+static int print_config = 0;
static int restarted = 0;
static char *rtc_device;
static int acquisition_port = -1;
/* ================================================== */
+void
+CNF_EnablePrint(void)
+{
+ print_config = 1;
+}
+
+/* ================================================== */
+
/* Read the configuration file */
void
CNF_ReadFile(const char *filename)
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")) {
extern void CNF_Initialise(int restarted, int client_only);
extern void CNF_Finalise(void);
+extern void CNF_EnablePrint(void);
+
extern char *CNF_GetRtcDevice(void);
extern void CNF_ReadFile(const char *filename);
0 (informational), 1 (warning), 2 (non-fatal error), and 3 (fatal error). The
default value is 0.
+*-p*::
+When run in this mode, *chronyd* will print the configuration and exit. It will
+not detach from the terminal. This option can be used to verify the syntax of
+the configuration and get the whole configuration, even if it is split into
+multiple files and read by the *include* or *confdirs* directive.
+
*-q*::
When run in this mode, *chronyd* will set the system clock once and exit. It
will not detach from the terminal.
static void
print_help(const char *progname)
{
- printf("Usage: %s [-4|-6] [-n|-d] [-q|-Q] [-r] [-R] [-s] [-t TIMEOUT] [-f FILE|COMMAND...]\n",
+ printf("Usage: %s [-4|-6] [-n|-d] [-p|-q|-Q] [-r] [-R] [-s] [-t TIMEOUT] [-f FILE|COMMAND...]\n",
progname);
}
int do_init_rtc = 0, restarted = 0, client_only = 0, timeout = -1;
int scfilter_level = 0, lock_memory = 0, sched_priority = 0;
int clock_control = 1, system_log = 1, log_severity = LOGS_INFO;
- int config_args = 0;
+ int config_args = 0, print_config = 0;
do_platform_checks();
optind = 1;
/* Parse short command-line options */
- while ((opt = getopt(argc, argv, "46df:F:hl:L:mnP:qQrRst:u:vx")) != -1) {
+ while ((opt = getopt(argc, argv, "46df:F:hl:L:mnpP:qQrRst:u:vx")) != -1) {
switch (opt) {
case '4':
case '6':
case 'n':
nofork = 1;
break;
+ case 'p':
+ print_config = 1;
+ client_only = 1;
+ nofork = 1;
+ system_log = 0;
+ break;
case 'P':
sched_priority = parse_int_arg(optarg);
break;
DNS_SetAddressFamily(address_family);
CNF_Initialise(restarted, client_only);
+ if (print_config)
+ CNF_EnablePrint();
/* Parse the config file or the remaining command line arguments */
config_args = argc - optind;
CNF_ParseLine(NULL, config_args + optind - argc + 1, argv[optind]);
}
+ if (print_config)
+ return 0;
+
/* Check whether another chronyd may already be running */
check_pidfile();