2 chronyd/chronyc - Programs for keeping computer clocks accurate.
4 **********************************************************************
5 * Copyright (C) Richard P. Curnow 1997-2003
6 * Copyright (C) Miroslav Lichvar 2009-2017
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of version 2 of the GNU General Public License as
10 * published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 **********************************************************************
23 =======================================================================
25 Module that reads and processes the configuration file.
34 #include "ntp_sources.h"
38 #include "srcparams.h"
45 /* ================================================== */
46 /* Forward prototypes */
48 static int parse_string(char *line
, char **result
);
49 static int parse_int(char *line
, int *result
);
50 static int parse_double(char *line
, double *result
);
51 static int parse_null(char *line
);
53 static void parse_allow_deny(char *line
, ARR_Instance restrictions
, int allow
);
54 static void parse_bindacqaddress(char *);
55 static void parse_bindaddress(char *);
56 static void parse_bindcmdaddress(char *);
57 static void parse_broadcast(char *);
58 static void parse_clientloglimit(char *);
59 static void parse_fallbackdrift(char *);
60 static void parse_hwtimestamp(char *);
61 static void parse_include(char *);
62 static void parse_initstepslew(char *);
63 static void parse_leapsecmode(char *);
64 static void parse_local(char *);
65 static void parse_log(char *);
66 static void parse_mailonchange(char *);
67 static void parse_makestep(char *);
68 static void parse_maxchange(char *);
69 static void parse_ratelimit(char *line
, int *enabled
, int *interval
,
70 int *burst
, int *leak
);
71 static void parse_refclock(char *);
72 static void parse_smoothtime(char *);
73 static void parse_source(char *line
, NTP_Source_Type type
, int pool
);
74 static void parse_tempcomp(char *);
76 /* ================================================== */
77 /* Configuration variables */
79 static int restarted
= 0;
80 static char *rtc_device
;
81 static int acquisition_port
= -1;
82 static int ntp_port
= NTP_PORT
;
83 static char *keys_file
= NULL
;
84 static char *drift_file
= NULL
;
85 static char *rtc_file
= NULL
;
86 static double max_update_skew
= 1000.0;
87 static double correction_time_ratio
= 3.0;
88 static double max_clock_error
= 1.0; /* in ppm */
89 static double max_drift
= 500000.0; /* in ppm */
90 static double max_slew_rate
= 1e6
/ 12.0; /* in ppm */
92 static double max_distance
= 3.0;
93 static double max_jitter
= 1.0;
94 static double reselect_distance
= 1e-4;
95 static double stratum_weight
= 1e-3;
96 static double combine_limit
= 3.0;
98 static int cmd_port
= DEFAULT_CANDM_PORT
;
100 static int raw_measurements
= 0;
101 static int do_log_measurements
= 0;
102 static int do_log_statistics
= 0;
103 static int do_log_tracking
= 0;
104 static int do_log_rtc
= 0;
105 static int do_log_refclocks
= 0;
106 static int do_log_tempcomp
= 0;
107 static int log_banner
= 32;
109 static char *dumpdir
;
111 static int enable_local
=0;
112 static int local_stratum
;
113 static int local_orphan
;
114 static double local_distance
;
116 /* Threshold (in seconds) - if absolute value of initial error is less
117 than this, slew instead of stepping */
118 static double init_slew_threshold
;
119 /* Array of IPAddr */
120 static ARR_Instance init_sources
;
122 static int enable_manual
=0;
124 /* Flag set if the RTC runs UTC (default is it runs local time
125 incl. daylight saving). */
126 static int rtc_on_utc
= 0;
128 /* Filename used to read the hwclock(8) LOCAL/UTC setting */
129 static char *hwclock_file
;
131 /* Flag set if the RTC should be automatically synchronised by kernel */
132 static int rtc_sync
= 0;
134 /* Limit and threshold for clock stepping */
135 static int make_step_limit
= 0;
136 static double make_step_threshold
= 0.0;
138 /* Threshold for automatic RTC trimming */
139 static double rtc_autotrim_threshold
= 0.0;
141 /* Minimum number of selectables sources required to update the clock */
142 static int min_sources
= 1;
144 /* Number of updates before offset checking, number of ignored updates
145 before exiting and the maximum allowed offset */
146 static int max_offset_delay
= -1;
147 static int max_offset_ignore
;
148 static double max_offset
;
150 /* Maximum and minimum number of samples per source */
151 static int max_samples
= 0; /* no limit */
152 static int min_samples
= 6;
154 /* Threshold for a time adjustment to be logged to syslog */
155 static double log_change_threshold
= 1.0;
157 static char *mail_user_on_change
= NULL
;
158 static double mail_change_threshold
= 0.0;
160 /* Flag indicating that we don't want to log clients, e.g. to save
162 static int no_client_log
= 0;
164 /* Limit memory allocated for the clients log */
165 static unsigned long client_log_limit
= 524288;
167 /* Minimum and maximum fallback drift intervals */
168 static int fb_drift_min
= 0;
169 static int fb_drift_max
= 0;
171 /* IP addresses for binding the NTP server sockets to. UNSPEC family means
172 INADDR_ANY will be used */
173 static IPAddr bind_address4
, bind_address6
;
175 /* IP addresses for binding the NTP client sockets to. UNSPEC family means
176 INADDR_ANY will be used */
177 static IPAddr bind_acq_address4
, bind_acq_address6
;
179 /* IP addresses for binding the command socket to. UNSPEC family means
180 the loopback address will be used */
181 static IPAddr bind_cmd_address4
, bind_cmd_address6
;
183 /* Path to the Unix domain command socket. */
184 static char *bind_cmd_path
;
186 /* Path to Samba (ntp_signd) socket. */
187 static char *ntp_signd_socket
= NULL
;
189 /* Filename to use for storing pid of running chronyd, to prevent multiple
190 * chronyds being started. */
191 static char *pidfile
;
193 /* Rate limiting parameters */
194 static int ntp_ratelimit_enabled
= 0;
195 static int ntp_ratelimit_interval
= 3;
196 static int ntp_ratelimit_burst
= 8;
197 static int ntp_ratelimit_leak
= 2;
198 static int cmd_ratelimit_enabled
= 0;
199 static int cmd_ratelimit_interval
= -4;
200 static int cmd_ratelimit_burst
= 8;
201 static int cmd_ratelimit_leak
= 2;
203 /* Smoothing constants */
204 static double smooth_max_freq
= 0.0; /* in ppm */
205 static double smooth_max_wander
= 0.0; /* in ppm/s */
206 static int smooth_leap_only
= 0;
208 /* Temperature sensor, update interval and compensation coefficients */
209 static char *tempcomp_sensor_file
= NULL
;
210 static char *tempcomp_point_file
= NULL
;
211 static double tempcomp_interval
;
212 static double tempcomp_T0
, tempcomp_k0
, tempcomp_k1
, tempcomp_k2
;
214 static int sched_priority
= 0;
215 static int lock_memory
= 0;
217 /* Leap second handling mode */
218 static REF_LeapMode leapsec_mode
= REF_LeapModeSystem
;
220 /* Name of a system timezone containing leap seconds occuring at midnight */
221 static char *leapsec_tz
= NULL
;
223 /* Name of the user to which will be dropped root privileges. */
226 /* NTS cache dir, certificates, private key, and port */
227 static char *nts_cachedir
= NULL
;
228 static char *nts_server_cert_file
= NULL
;
229 static char *nts_server_key_file
= NULL
;
230 static int nts_server_port
= 11443;
231 static int nts_server_processes
= 1;
232 static int nts_server_connections
= 100;
233 static int nts_refresh
= 2419200; /* 4 weeks */
234 static int nts_rotate
= 604800; /* 1 week */
235 static char *nts_trusted_cert_file
= NULL
;
237 /* Flag disabling use of system trusted certificates */
238 static int no_system_cert
= 0;
240 /* Array of CNF_HwTsInterface */
241 static ARR_Instance hwts_interfaces
;
244 NTP_Source_Type type
;
246 CPS_NTP_Source params
;
249 /* Array of NTP_Source */
250 static ARR_Instance ntp_sources
;
252 /* Array of RefclockParameters */
253 static ARR_Instance refclock_sources
;
255 typedef struct _AllowDeny
{
258 int all
; /* 1 to override existing more specific defns */
259 int allow
; /* 0 for deny, 1 for allow */
262 /* Arrays of AllowDeny */
263 static ARR_Instance ntp_restrictions
;
264 static ARR_Instance cmd_restrictions
;
270 } NTP_Broadcast_Destination
;
272 /* Array of NTP_Broadcast_Destination */
273 static ARR_Instance broadcasts
;
275 /* ================================================== */
277 /* The line number in the configuration file being processed */
278 static int line_number
;
279 static const char *processed_file
;
280 static const char *processed_command
;
282 /* ================================================== */
285 command_parse_error(void)
287 LOG_FATAL("Could not parse %s directive at line %d%s%s",
288 processed_command
, line_number
, processed_file
? " in file " : "",
289 processed_file
? processed_file
: "");
292 /* ================================================== */
295 other_parse_error(const char *message
)
297 LOG_FATAL("%s at line %d%s%s",
298 message
, line_number
, processed_file
? " in file " : "",
299 processed_file
? processed_file
: "");
302 /* ================================================== */
305 get_number_of_args(char *line
)
309 /* The line is normalized, between arguments is just one space */
314 for (; *line
; line
++) {
322 /* ================================================== */
325 check_number_of_args(char *line
, int num
)
327 num
-= get_number_of_args(line
);
330 LOG_FATAL("%s arguments for %s directive at line %d%s%s",
331 num
> 0 ? "Missing" : "Too many",
332 processed_command
, line_number
, processed_file
? " in file " : "",
333 processed_file
? processed_file
: "");
337 /* ================================================== */
340 CNF_Initialise(int r
, int client_only
)
344 hwts_interfaces
= ARR_CreateInstance(sizeof (CNF_HwTsInterface
));
346 init_sources
= ARR_CreateInstance(sizeof (IPAddr
));
347 ntp_sources
= ARR_CreateInstance(sizeof (NTP_Source
));
348 refclock_sources
= ARR_CreateInstance(sizeof (RefclockParameters
));
349 broadcasts
= ARR_CreateInstance(sizeof (NTP_Broadcast_Destination
));
351 ntp_restrictions
= ARR_CreateInstance(sizeof (AllowDeny
));
352 cmd_restrictions
= ARR_CreateInstance(sizeof (AllowDeny
));
354 dumpdir
= Strdup("");
356 rtc_device
= Strdup(DEFAULT_RTC_DEVICE
);
357 hwclock_file
= Strdup(DEFAULT_HWCLOCK_FILE
);
358 user
= Strdup(DEFAULT_USER
);
361 cmd_port
= ntp_port
= 0;
362 bind_cmd_path
= Strdup("");
363 pidfile
= Strdup("");
365 bind_cmd_path
= Strdup(DEFAULT_COMMAND_SOCKET
);
366 pidfile
= Strdup(DEFAULT_PID_FILE
);
370 /* ================================================== */
377 for (i
= 0; i
< ARR_GetSize(hwts_interfaces
); i
++)
378 Free(((CNF_HwTsInterface
*)ARR_GetElement(hwts_interfaces
, i
))->name
);
379 ARR_DestroyInstance(hwts_interfaces
);
381 for (i
= 0; i
< ARR_GetSize(ntp_sources
); i
++)
382 Free(((NTP_Source
*)ARR_GetElement(ntp_sources
, i
))->params
.name
);
384 ARR_DestroyInstance(init_sources
);
385 ARR_DestroyInstance(ntp_sources
);
386 ARR_DestroyInstance(refclock_sources
);
387 ARR_DestroyInstance(broadcasts
);
389 ARR_DestroyInstance(ntp_restrictions
);
390 ARR_DestroyInstance(cmd_restrictions
);
399 Free(ntp_signd_socket
);
404 Free(mail_user_on_change
);
405 Free(tempcomp_sensor_file
);
406 Free(tempcomp_point_file
);
408 Free(nts_server_cert_file
);
409 Free(nts_server_key_file
);
410 Free(nts_trusted_cert_file
);
413 /* ================================================== */
415 /* Read the configuration file */
417 CNF_ReadFile(const char *filename
)
423 in
= UTI_OpenFile(NULL
, filename
, NULL
, 'R', 0);
425 for (i
= 1; fgets(line
, sizeof(line
), in
); i
++) {
426 CNF_ParseLine(filename
, i
, line
);
432 /* ================================================== */
434 /* Parse one configuration line */
436 CNF_ParseLine(const char *filename
, int number
, char *line
)
440 /* Set global variables used in error messages */
441 processed_file
= filename
;
442 line_number
= number
;
444 /* Remove extra white-space and comments */
445 CPS_NormalizeLine(line
);
447 /* Skip blank lines */
451 /* We have a real line, now try to match commands */
452 processed_command
= command
= line
;
453 p
= CPS_SplitWord(line
);
455 if (!strcasecmp(command
, "acquisitionport")) {
456 parse_int(p
, &acquisition_port
);
457 } else if (!strcasecmp(command
, "allow")) {
458 parse_allow_deny(p
, ntp_restrictions
, 1);
459 } else if (!strcasecmp(command
, "bindacqaddress")) {
460 parse_bindacqaddress(p
);
461 } else if (!strcasecmp(command
, "bindaddress")) {
462 parse_bindaddress(p
);
463 } else if (!strcasecmp(command
, "bindcmdaddress")) {
464 parse_bindcmdaddress(p
);
465 } else if (!strcasecmp(command
, "broadcast")) {
467 } else if (!strcasecmp(command
, "clientloglimit")) {
468 parse_clientloglimit(p
);
469 } else if (!strcasecmp(command
, "cmdallow")) {
470 parse_allow_deny(p
, cmd_restrictions
, 1);
471 } else if (!strcasecmp(command
, "cmddeny")) {
472 parse_allow_deny(p
, cmd_restrictions
, 0);
473 } else if (!strcasecmp(command
, "cmdport")) {
474 parse_int(p
, &cmd_port
);
475 } else if (!strcasecmp(command
, "cmdratelimit")) {
476 parse_ratelimit(p
, &cmd_ratelimit_enabled
, &cmd_ratelimit_interval
,
477 &cmd_ratelimit_burst
, &cmd_ratelimit_leak
);
478 } else if (!strcasecmp(command
, "combinelimit")) {
479 parse_double(p
, &combine_limit
);
480 } else if (!strcasecmp(command
, "corrtimeratio")) {
481 parse_double(p
, &correction_time_ratio
);
482 } else if (!strcasecmp(command
, "deny")) {
483 parse_allow_deny(p
, ntp_restrictions
, 0);
484 } else if (!strcasecmp(command
, "driftfile")) {
485 parse_string(p
, &drift_file
);
486 } else if (!strcasecmp(command
, "dumpdir")) {
487 parse_string(p
, &dumpdir
);
488 } else if (!strcasecmp(command
, "dumponexit")) {
489 /* Silently ignored */
490 } else if (!strcasecmp(command
, "fallbackdrift")) {
491 parse_fallbackdrift(p
);
492 } else if (!strcasecmp(command
, "hwclockfile")) {
493 parse_string(p
, &hwclock_file
);
494 } else if (!strcasecmp(command
, "hwtimestamp")) {
495 parse_hwtimestamp(p
);
496 } else if (!strcasecmp(command
, "include")) {
498 } else if (!strcasecmp(command
, "initstepslew")) {
499 parse_initstepslew(p
);
500 } else if (!strcasecmp(command
, "keyfile")) {
501 parse_string(p
, &keys_file
);
502 } else if (!strcasecmp(command
, "leapsecmode")) {
503 parse_leapsecmode(p
);
504 } else if (!strcasecmp(command
, "leapsectz")) {
505 parse_string(p
, &leapsec_tz
);
506 } else if (!strcasecmp(command
, "local")) {
508 } else if (!strcasecmp(command
, "lock_all")) {
509 lock_memory
= parse_null(p
);
510 } else if (!strcasecmp(command
, "log")) {
512 } else if (!strcasecmp(command
, "logbanner")) {
513 parse_int(p
, &log_banner
);
514 } else if (!strcasecmp(command
, "logchange")) {
515 parse_double(p
, &log_change_threshold
);
516 } else if (!strcasecmp(command
, "logdir")) {
517 parse_string(p
, &logdir
);
518 } else if (!strcasecmp(command
, "mailonchange")) {
519 parse_mailonchange(p
);
520 } else if (!strcasecmp(command
, "makestep")) {
522 } else if (!strcasecmp(command
, "manual")) {
523 enable_manual
= parse_null(p
);
524 } else if (!strcasecmp(command
, "maxchange")) {
526 } else if (!strcasecmp(command
, "maxclockerror")) {
527 parse_double(p
, &max_clock_error
);
528 } else if (!strcasecmp(command
, "maxdistance")) {
529 parse_double(p
, &max_distance
);
530 } else if (!strcasecmp(command
, "maxdrift")) {
531 parse_double(p
, &max_drift
);
532 } else if (!strcasecmp(command
, "maxjitter")) {
533 parse_double(p
, &max_jitter
);
534 } else if (!strcasecmp(command
, "maxntsconnections")) {
535 parse_int(p
, &nts_server_connections
);
536 } else if (!strcasecmp(command
, "maxsamples")) {
537 parse_int(p
, &max_samples
);
538 } else if (!strcasecmp(command
, "maxslewrate")) {
539 parse_double(p
, &max_slew_rate
);
540 } else if (!strcasecmp(command
, "maxupdateskew")) {
541 parse_double(p
, &max_update_skew
);
542 } else if (!strcasecmp(command
, "minsamples")) {
543 parse_int(p
, &min_samples
);
544 } else if (!strcasecmp(command
, "minsources")) {
545 parse_int(p
, &min_sources
);
546 } else if (!strcasecmp(command
, "noclientlog")) {
547 no_client_log
= parse_null(p
);
548 } else if (!strcasecmp(command
, "nosystemcert")) {
549 no_system_cert
= parse_null(p
);
550 } else if (!strcasecmp(command
, "ntpsigndsocket")) {
551 parse_string(p
, &ntp_signd_socket
);
552 } else if (!strcasecmp(command
, "ntstrustedcerts")) {
553 parse_string(p
, &nts_trusted_cert_file
);
554 } else if (!strcasecmp(command
, "ntscachedir")) {
555 parse_string(p
, &nts_cachedir
);
556 } else if (!strcasecmp(command
, "ntsport")) {
557 parse_int(p
, &nts_server_port
);
558 } else if (!strcasecmp(command
, "ntsprocesses")) {
559 parse_int(p
, &nts_server_processes
);
560 } else if (!strcasecmp(command
, "ntsrefresh")) {
561 parse_int(p
, &nts_refresh
);
562 } else if (!strcasecmp(command
, "ntsrotate")) {
563 parse_int(p
, &nts_rotate
);
564 } else if (!strcasecmp(command
, "ntsservercert")) {
565 parse_string(p
, &nts_server_cert_file
);
566 } else if (!strcasecmp(command
, "ntsserverkey")) {
567 parse_string(p
, &nts_server_key_file
);
568 } else if (!strcasecmp(command
, "peer")) {
569 parse_source(p
, NTP_PEER
, 0);
570 } else if (!strcasecmp(command
, "pidfile")) {
571 parse_string(p
, &pidfile
);
572 } else if (!strcasecmp(command
, "pool")) {
573 parse_source(p
, NTP_SERVER
, 1);
574 } else if (!strcasecmp(command
, "port")) {
575 parse_int(p
, &ntp_port
);
576 } else if (!strcasecmp(command
, "ratelimit")) {
577 parse_ratelimit(p
, &ntp_ratelimit_enabled
, &ntp_ratelimit_interval
,
578 &ntp_ratelimit_burst
, &ntp_ratelimit_leak
);
579 } else if (!strcasecmp(command
, "refclock")) {
581 } else if (!strcasecmp(command
, "reselectdist")) {
582 parse_double(p
, &reselect_distance
);
583 } else if (!strcasecmp(command
, "rtcautotrim")) {
584 parse_double(p
, &rtc_autotrim_threshold
);
585 } else if (!strcasecmp(command
, "rtcdevice")) {
586 parse_string(p
, &rtc_device
);
587 } else if (!strcasecmp(command
, "rtcfile")) {
588 parse_string(p
, &rtc_file
);
589 } else if (!strcasecmp(command
, "rtconutc")) {
590 rtc_on_utc
= parse_null(p
);
591 } else if (!strcasecmp(command
, "rtcsync")) {
592 rtc_sync
= parse_null(p
);
593 } else if (!strcasecmp(command
, "sched_priority")) {
594 parse_int(p
, &sched_priority
);
595 } else if (!strcasecmp(command
, "server")) {
596 parse_source(p
, NTP_SERVER
, 0);
597 } else if (!strcasecmp(command
, "smoothtime")) {
599 } else if (!strcasecmp(command
, "stratumweight")) {
600 parse_double(p
, &stratum_weight
);
601 } else if (!strcasecmp(command
, "tempcomp")) {
603 } else if (!strcasecmp(command
, "user")) {
604 parse_string(p
, &user
);
605 } else if (!strcasecmp(command
, "commandkey") ||
606 !strcasecmp(command
, "generatecommandkey") ||
607 !strcasecmp(command
, "linux_freq_scale") ||
608 !strcasecmp(command
, "linux_hz")) {
609 LOG(LOGS_WARN
, "%s directive is no longer supported", command
);
611 other_parse_error("Invalid command");
615 /* ================================================== */
618 parse_string(char *line
, char **result
)
620 check_number_of_args(line
, 1);
622 *result
= Strdup(line
);
626 /* ================================================== */
629 parse_int(char *line
, int *result
)
631 check_number_of_args(line
, 1);
632 if (sscanf(line
, "%d", result
) != 1) {
633 command_parse_error();
639 /* ================================================== */
642 parse_double(char *line
, double *result
)
644 check_number_of_args(line
, 1);
645 if (sscanf(line
, "%lf", result
) != 1) {
646 command_parse_error();
652 /* ================================================== */
655 parse_null(char *line
)
657 check_number_of_args(line
, 0);
661 /* ================================================== */
664 parse_source(char *line
, NTP_Source_Type type
, int pool
)
671 if (!CPS_ParseNTPSourceAdd(line
, &source
.params
)) {
672 command_parse_error();
676 source
.params
.name
= Strdup(source
.params
.name
);
677 ARR_AppendElement(ntp_sources
, &source
);
680 /* ================================================== */
683 parse_ratelimit(char *line
, int *enabled
, int *interval
, int *burst
, int *leak
)
692 line
= CPS_SplitWord(line
);
693 if (sscanf(line
, "%d%n", &val
, &n
) != 1) {
694 command_parse_error();
698 if (!strcasecmp(opt
, "interval"))
700 else if (!strcasecmp(opt
, "burst"))
702 else if (!strcasecmp(opt
, "leak"))
705 command_parse_error();
709 /* ================================================== */
712 parse_refclock(char *line
)
714 int n
, poll
, dpoll
, filter_length
, pps_rate
, min_samples
, max_samples
, sel_options
;
715 int max_lock_age
, pps_forced
, stratum
, tai
;
716 uint32_t ref_id
, lock_ref_id
;
717 double offset
, delay
, precision
, max_dispersion
, pulse_width
;
718 char *p
, *cmd
, *name
, *param
;
719 unsigned char ref
[5];
720 RefclockParameters
*refclock
;
727 min_samples
= SRC_DEFAULT_MINSAMPLES
;
728 max_samples
= SRC_DEFAULT_MAXSAMPLES
;
733 max_dispersion
= 0.0;
742 command_parse_error();
747 line
= CPS_SplitWord(line
);
750 command_parse_error();
757 line
= CPS_SplitWord(line
);
760 for (cmd
= line
; *cmd
; line
+= n
, cmd
= line
) {
761 line
= CPS_SplitWord(line
);
763 if (!strcasecmp(cmd
, "refid")) {
764 if (sscanf(line
, "%4s%n", (char *)ref
, &n
) != 1)
766 ref_id
= (uint32_t)ref
[0] << 24 | ref
[1] << 16 | ref
[2] << 8 | ref
[3];
767 } else if (!strcasecmp(cmd
, "lock")) {
768 if (sscanf(line
, "%4s%n", (char *)ref
, &n
) != 1)
770 lock_ref_id
= (uint32_t)ref
[0] << 24 | ref
[1] << 16 | ref
[2] << 8 | ref
[3];
771 } else if (!strcasecmp(cmd
, "poll")) {
772 if (sscanf(line
, "%d%n", &poll
, &n
) != 1) {
775 } else if (!strcasecmp(cmd
, "dpoll")) {
776 if (sscanf(line
, "%d%n", &dpoll
, &n
) != 1) {
779 } else if (!strcasecmp(cmd
, "filter")) {
780 if (sscanf(line
, "%d%n", &filter_length
, &n
) != 1) {
783 } else if (!strcasecmp(cmd
, "rate")) {
784 if (sscanf(line
, "%d%n", &pps_rate
, &n
) != 1)
786 } else if (!strcasecmp(cmd
, "minsamples")) {
787 if (sscanf(line
, "%d%n", &min_samples
, &n
) != 1)
789 } else if (!strcasecmp(cmd
, "maxlockage")) {
790 if (sscanf(line
, "%d%n", &max_lock_age
, &n
) != 1)
792 } else if (!strcasecmp(cmd
, "maxsamples")) {
793 if (sscanf(line
, "%d%n", &max_samples
, &n
) != 1)
795 } else if (!strcasecmp(cmd
, "offset")) {
796 if (sscanf(line
, "%lf%n", &offset
, &n
) != 1)
798 } else if (!strcasecmp(cmd
, "delay")) {
799 if (sscanf(line
, "%lf%n", &delay
, &n
) != 1)
801 } else if (!strcasecmp(cmd
, "pps")) {
804 } else if (!strcasecmp(cmd
, "precision")) {
805 if (sscanf(line
, "%lf%n", &precision
, &n
) != 1)
807 } else if (!strcasecmp(cmd
, "maxdispersion")) {
808 if (sscanf(line
, "%lf%n", &max_dispersion
, &n
) != 1)
810 } else if (!strcasecmp(cmd
, "stratum")) {
811 if (sscanf(line
, "%d%n", &stratum
, &n
) != 1 ||
812 stratum
>= NTP_MAX_STRATUM
|| stratum
< 0)
814 } else if (!strcasecmp(cmd
, "tai")) {
817 } else if (!strcasecmp(cmd
, "width")) {
818 if (sscanf(line
, "%lf%n", &pulse_width
, &n
) != 1)
820 } else if (!strcasecmp(cmd
, "noselect")) {
822 sel_options
|= SRC_SELECT_NOSELECT
;
823 } else if (!strcasecmp(cmd
, "prefer")) {
825 sel_options
|= SRC_SELECT_PREFER
;
826 } else if (!strcasecmp(cmd
, "trust")) {
828 sel_options
|= SRC_SELECT_TRUST
;
829 } else if (!strcasecmp(cmd
, "require")) {
831 sel_options
|= SRC_SELECT_REQUIRE
;
833 other_parse_error("Invalid refclock option");
839 command_parse_error();
843 refclock
= (RefclockParameters
*)ARR_GetNewElement(refclock_sources
);
844 refclock
->driver_name
= name
;
845 refclock
->driver_parameter
= param
;
846 refclock
->driver_poll
= dpoll
;
847 refclock
->poll
= poll
;
848 refclock
->filter_length
= filter_length
;
849 refclock
->pps_forced
= pps_forced
;
850 refclock
->pps_rate
= pps_rate
;
851 refclock
->min_samples
= min_samples
;
852 refclock
->max_samples
= max_samples
;
853 refclock
->sel_options
= sel_options
;
854 refclock
->stratum
= stratum
;
856 refclock
->offset
= offset
;
857 refclock
->delay
= delay
;
858 refclock
->precision
= precision
;
859 refclock
->max_dispersion
= max_dispersion
;
860 refclock
->pulse_width
= pulse_width
;
861 refclock
->ref_id
= ref_id
;
862 refclock
->max_lock_age
= max_lock_age
;
863 refclock
->lock_ref_id
= lock_ref_id
;
866 /* ================================================== */
869 parse_log(char *line
)
874 line
= CPS_SplitWord(line
);
876 if (!strcmp(log_name
, "rawmeasurements")) {
877 do_log_measurements
= 1;
878 raw_measurements
= 1;
879 } else if (!strcmp(log_name
, "measurements")) {
880 do_log_measurements
= 1;
881 } else if (!strcmp(log_name
, "statistics")) {
882 do_log_statistics
= 1;
883 } else if (!strcmp(log_name
, "tracking")) {
885 } else if (!strcmp(log_name
, "rtc")) {
887 } else if (!strcmp(log_name
, "refclocks")) {
888 do_log_refclocks
= 1;
889 } else if (!strcmp(log_name
, "tempcomp")) {
892 other_parse_error("Invalid log parameter");
901 /* ================================================== */
904 parse_local(char *line
)
906 if (!CPS_ParseLocal(line
, &local_stratum
, &local_orphan
, &local_distance
))
907 command_parse_error();
911 /* ================================================== */
914 parse_initstepslew(char *line
)
919 /* Ignore the line if chronyd was started with -R. */
924 ARR_SetSize(init_sources
, 0);
925 p
= CPS_SplitWord(line
);
927 if (sscanf(line
, "%lf", &init_slew_threshold
) != 1) {
928 command_parse_error();
934 p
= CPS_SplitWord(p
);
936 if (DNS_Name2IPAddress(hostname
, &ip_addr
, 1) == DNS_Success
) {
937 ARR_AppendElement(init_sources
, &ip_addr
);
939 LOG(LOGS_WARN
, "Could not resolve address of initstepslew server %s", hostname
);
945 /* ================================================== */
948 parse_leapsecmode(char *line
)
950 if (!strcasecmp(line
, "system"))
951 leapsec_mode
= REF_LeapModeSystem
;
952 else if (!strcasecmp(line
, "slew"))
953 leapsec_mode
= REF_LeapModeSlew
;
954 else if (!strcasecmp(line
, "step"))
955 leapsec_mode
= REF_LeapModeStep
;
956 else if (!strcasecmp(line
, "ignore"))
957 leapsec_mode
= REF_LeapModeIgnore
;
959 command_parse_error();
962 /* ================================================== */
965 parse_clientloglimit(char *line
)
967 check_number_of_args(line
, 1);
968 if (sscanf(line
, "%lu", &client_log_limit
) != 1) {
969 command_parse_error();
973 /* ================================================== */
976 parse_fallbackdrift(char *line
)
978 check_number_of_args(line
, 2);
979 if (sscanf(line
, "%d %d", &fb_drift_min
, &fb_drift_max
) != 2) {
980 command_parse_error();
984 /* ================================================== */
987 parse_makestep(char *line
)
989 check_number_of_args(line
, 2);
990 if (sscanf(line
, "%lf %d", &make_step_threshold
, &make_step_limit
) != 2) {
992 command_parse_error();
995 /* Disable limited makestep if chronyd was started with -R. */
996 if (restarted
&& make_step_limit
> 0) {
1001 /* ================================================== */
1004 parse_maxchange(char *line
)
1006 check_number_of_args(line
, 3);
1007 if (sscanf(line
, "%lf %d %d", &max_offset
, &max_offset_delay
, &max_offset_ignore
) != 3) {
1008 max_offset_delay
= -1;
1009 command_parse_error();
1013 /* ================================================== */
1016 parse_mailonchange(char *line
)
1019 check_number_of_args(line
, 2);
1021 line
= CPS_SplitWord(line
);
1022 Free(mail_user_on_change
);
1023 if (sscanf(line
, "%lf", &mail_change_threshold
) == 1) {
1024 mail_user_on_change
= Strdup(address
);
1026 mail_user_on_change
= NULL
;
1027 command_parse_error();
1031 /* ================================================== */
1034 parse_allow_deny(char *line
, ARR_Instance restrictions
, int allow
)
1037 unsigned long a
, b
, c
, d
, n
;
1039 AllowDeny
*new_node
= NULL
;
1044 if (!strncmp(p
, "all", 3)) {
1046 p
= CPS_SplitWord(line
);
1050 /* Empty line applies to all addresses */
1051 new_node
= (AllowDeny
*)ARR_GetNewElement(restrictions
);
1052 new_node
->allow
= allow
;
1053 new_node
->all
= all
;
1054 new_node
->ip
.family
= IPADDR_UNSPEC
;
1055 new_node
->subnet_bits
= 0;
1058 slashpos
= strchr(p
, '/');
1059 if (slashpos
) *slashpos
= 0;
1061 check_number_of_args(p
, 1);
1063 if (UTI_StringToIP(p
, &ip_addr
) ||
1064 (n
= sscanf(p
, "%lu.%lu.%lu.%lu", &a
, &b
, &c
, &d
)) >= 1) {
1065 new_node
= (AllowDeny
*)ARR_GetNewElement(restrictions
);
1066 new_node
->allow
= allow
;
1067 new_node
->all
= all
;
1070 new_node
->ip
= ip_addr
;
1071 if (ip_addr
.family
== IPADDR_INET6
)
1072 new_node
->subnet_bits
= 128;
1074 new_node
->subnet_bits
= 32;
1076 new_node
->ip
.family
= IPADDR_INET4
;
1085 new_node
->ip
.addr
.in4
= (a
<<24);
1086 new_node
->subnet_bits
= 8;
1089 new_node
->ip
.addr
.in4
= (a
<<24) | (b
<<16);
1090 new_node
->subnet_bits
= 16;
1093 new_node
->ip
.addr
.in4
= (a
<<24) | (b
<<16) | (c
<<8);
1094 new_node
->subnet_bits
= 24;
1097 new_node
->ip
.addr
.in4
= (a
<<24) | (b
<<16) | (c
<<8) | d
;
1098 new_node
->subnet_bits
= 32;
1106 int specified_subnet_bits
, n
;
1107 n
= sscanf(slashpos
+1, "%d", &specified_subnet_bits
);
1109 new_node
->subnet_bits
= specified_subnet_bits
;
1111 command_parse_error();
1116 if (!slashpos
&& DNS_Name2IPAddress(p
, &ip_addr
, 1) == DNS_Success
) {
1117 new_node
= (AllowDeny
*)ARR_GetNewElement(restrictions
);
1118 new_node
->allow
= allow
;
1119 new_node
->all
= all
;
1120 new_node
->ip
= ip_addr
;
1121 if (ip_addr
.family
== IPADDR_INET6
)
1122 new_node
->subnet_bits
= 128;
1124 new_node
->subnet_bits
= 32;
1126 command_parse_error();
1132 /* ================================================== */
1135 parse_bindacqaddress(char *line
)
1139 check_number_of_args(line
, 1);
1140 if (UTI_StringToIP(line
, &ip
)) {
1141 if (ip
.family
== IPADDR_INET4
)
1142 bind_acq_address4
= ip
;
1143 else if (ip
.family
== IPADDR_INET6
)
1144 bind_acq_address6
= ip
;
1146 command_parse_error();
1150 /* ================================================== */
1153 parse_bindaddress(char *line
)
1157 check_number_of_args(line
, 1);
1158 if (UTI_StringToIP(line
, &ip
)) {
1159 if (ip
.family
== IPADDR_INET4
)
1161 else if (ip
.family
== IPADDR_INET6
)
1164 command_parse_error();
1168 /* ================================================== */
1171 parse_bindcmdaddress(char *line
)
1175 check_number_of_args(line
, 1);
1177 /* Address starting with / is for the Unix domain socket */
1178 if (line
[0] == '/') {
1179 parse_string(line
, &bind_cmd_path
);
1180 /* / disables the socket */
1181 if (!strcmp(bind_cmd_path
, "/"))
1182 bind_cmd_path
[0] = '\0';
1183 } else if (UTI_StringToIP(line
, &ip
)) {
1184 if (ip
.family
== IPADDR_INET4
)
1185 bind_cmd_address4
= ip
;
1186 else if (ip
.family
== IPADDR_INET6
)
1187 bind_cmd_address6
= ip
;
1189 command_parse_error();
1193 /* ================================================== */
1196 parse_broadcast(char *line
)
1198 /* Syntax : broadcast <interval> <broadcast-IP-addr> [<port>] */
1199 NTP_Broadcast_Destination
*destination
;
1206 line
= CPS_SplitWord(line
);
1208 if (sscanf(p
, "%d", &interval
) != 1) {
1209 command_parse_error();
1214 line
= CPS_SplitWord(line
);
1216 if (!UTI_StringToIP(p
, &ip
)) {
1217 command_parse_error();
1222 line
= CPS_SplitWord(line
);
1225 if (sscanf(p
, "%d", &port
) != 1 || *line
) {
1226 command_parse_error();
1234 destination
= (NTP_Broadcast_Destination
*)ARR_GetNewElement(broadcasts
);
1235 destination
->addr
= ip
;
1236 destination
->port
= port
;
1237 destination
->interval
= interval
;
1240 /* ================================================== */
1243 parse_smoothtime(char *line
)
1245 if (get_number_of_args(line
) != 3)
1246 check_number_of_args(line
, 2);
1248 if (sscanf(line
, "%lf %lf", &smooth_max_freq
, &smooth_max_wander
) != 2) {
1249 smooth_max_freq
= 0.0;
1250 command_parse_error();
1253 line
= CPS_SplitWord(CPS_SplitWord(line
));
1254 smooth_leap_only
= 0;
1257 if (!strcasecmp(line
, "leaponly"))
1258 smooth_leap_only
= 1;
1260 command_parse_error();
1264 /* ================================================== */
1266 parse_tempcomp(char *line
)
1271 point_form
= get_number_of_args(line
) == 3;
1274 check_number_of_args(line
, 6);
1277 line
= CPS_SplitWord(line
);
1280 command_parse_error();
1284 Free(tempcomp_point_file
);
1287 if (sscanf(line
, "%lf", &tempcomp_interval
) != 1) {
1288 command_parse_error();
1291 tempcomp_point_file
= Strdup(CPS_SplitWord(line
));
1293 if (sscanf(line
, "%lf %lf %lf %lf %lf", &tempcomp_interval
,
1294 &tempcomp_T0
, &tempcomp_k0
, &tempcomp_k1
, &tempcomp_k2
) != 5) {
1295 command_parse_error();
1298 tempcomp_point_file
= NULL
;
1301 Free(tempcomp_sensor_file
);
1302 tempcomp_sensor_file
= Strdup(p
);
1305 /* ================================================== */
1308 parse_hwtimestamp(char *line
)
1310 CNF_HwTsInterface
*iface
;
1315 command_parse_error();
1320 line
= CPS_SplitWord(line
);
1322 iface
= ARR_GetNewElement(hwts_interfaces
);
1323 iface
->name
= Strdup(p
);
1325 iface
->min_samples
= 2;
1326 iface
->max_samples
= 16;
1327 iface
->nocrossts
= 0;
1328 iface
->rxfilter
= CNF_HWTS_RXFILTER_ANY
;
1329 iface
->precision
= 100.0e-9;
1330 iface
->tx_comp
= 0.0;
1331 iface
->rx_comp
= 0.0;
1333 for (p
= line
; *p
; line
+= n
, p
= line
) {
1334 line
= CPS_SplitWord(line
);
1336 if (!strcasecmp(p
, "maxsamples")) {
1337 if (sscanf(line
, "%d%n", &iface
->max_samples
, &n
) != 1)
1339 } else if (!strcasecmp(p
, "minpoll")) {
1340 if (sscanf(line
, "%d%n", &iface
->minpoll
, &n
) != 1)
1342 } else if (!strcasecmp(p
, "minsamples")) {
1343 if (sscanf(line
, "%d%n", &iface
->min_samples
, &n
) != 1)
1345 } else if (!strcasecmp(p
, "precision")) {
1346 if (sscanf(line
, "%lf%n", &iface
->precision
, &n
) != 1)
1348 } else if (!strcasecmp(p
, "rxcomp")) {
1349 if (sscanf(line
, "%lf%n", &iface
->rx_comp
, &n
) != 1)
1351 } else if (!strcasecmp(p
, "txcomp")) {
1352 if (sscanf(line
, "%lf%n", &iface
->tx_comp
, &n
) != 1)
1354 } else if (!strcasecmp(p
, "rxfilter")) {
1355 if (sscanf(line
, "%4s%n", filter
, &n
) != 1)
1357 if (!strcasecmp(filter
, "none"))
1358 iface
->rxfilter
= CNF_HWTS_RXFILTER_NONE
;
1359 else if (!strcasecmp(filter
, "ntp"))
1360 iface
->rxfilter
= CNF_HWTS_RXFILTER_NTP
;
1361 else if (!strcasecmp(filter
, "all"))
1362 iface
->rxfilter
= CNF_HWTS_RXFILTER_ALL
;
1365 } else if (!strcasecmp(p
, "nocrossts")) {
1367 iface
->nocrossts
= 1;
1374 command_parse_error();
1377 /* ================================================== */
1380 parse_include(char *line
)
1386 check_number_of_args(line
, 1);
1392 GLOB_ERR
, NULL
, &gl
)) != 0) {
1393 if (r
!= GLOB_NOMATCH
)
1394 LOG_FATAL("Could not search for files matching %s", line
);
1396 DEBUG_LOG("glob of %s failed", line
);
1400 for (i
= 0; i
< gl
.gl_pathc
; i
++)
1401 CNF_ReadFile(gl
.gl_pathv
[i
]);
1406 /* ================================================== */
1409 CNF_CreateDirs(uid_t uid
, gid_t gid
)
1413 /* Create a directory for the Unix domain command socket */
1414 if (bind_cmd_path
[0]) {
1415 dir
= UTI_PathToDir(bind_cmd_path
);
1416 UTI_CreateDirAndParents(dir
, 0770, uid
, gid
);
1418 /* Check the permissions and owner/group in case the directory already
1419 existed. It MUST NOT be accessible by others as permissions on Unix
1420 domain sockets are ignored on some systems (e.g. Solaris). */
1421 if (!UTI_CheckDirPermissions(dir
, 0770, uid
, gid
)) {
1422 LOG(LOGS_WARN
, "Disabled command socket %s", bind_cmd_path
);
1423 bind_cmd_path
[0] = '\0';
1430 UTI_CreateDirAndParents(logdir
, 0755, uid
, gid
);
1432 UTI_CreateDirAndParents(dumpdir
, 0755, uid
, gid
);
1435 /* ================================================== */
1438 CNF_AddInitSources(void)
1440 CPS_NTP_Source cps_source
;
1441 NTP_Remote_Address ntp_addr
;
1442 char dummy_hostname
[2] = "H";
1445 for (i
= 0; i
< ARR_GetSize(init_sources
); i
++) {
1446 /* Get the default NTP params */
1447 CPS_ParseNTPSourceAdd(dummy_hostname
, &cps_source
);
1449 /* Add the address as an offline iburst server */
1450 ntp_addr
.ip_addr
= *(IPAddr
*)ARR_GetElement(init_sources
, i
);
1451 ntp_addr
.port
= cps_source
.port
;
1452 cps_source
.params
.iburst
= 1;
1453 cps_source
.params
.connectivity
= SRC_OFFLINE
;
1455 NSR_AddSource(&ntp_addr
, NTP_SERVER
, &cps_source
.params
);
1458 ARR_SetSize(init_sources
, 0);
1461 /* ================================================== */
1464 CNF_AddSources(void)
1469 for (i
= 0; i
< ARR_GetSize(ntp_sources
); i
++) {
1470 source
= (NTP_Source
*)ARR_GetElement(ntp_sources
, i
);
1471 NSR_AddSourceByName(source
->params
.name
, source
->params
.port
,
1472 source
->pool
, source
->type
, &source
->params
.params
);
1473 Free(source
->params
.name
);
1476 ARR_SetSize(ntp_sources
, 0);
1479 /* ================================================== */
1482 CNF_AddRefclocks(void)
1486 for (i
= 0; i
< ARR_GetSize(refclock_sources
); i
++) {
1487 RCL_AddRefclock((RefclockParameters
*)ARR_GetElement(refclock_sources
, i
));
1490 ARR_SetSize(refclock_sources
, 0);
1493 /* ================================================== */
1496 CNF_AddBroadcasts(void)
1499 NTP_Broadcast_Destination
*destination
;
1501 for (i
= 0; i
< ARR_GetSize(broadcasts
); i
++) {
1502 destination
= (NTP_Broadcast_Destination
*)ARR_GetElement(broadcasts
, i
);
1503 NCR_AddBroadcastDestination(&destination
->addr
, destination
->port
,
1504 destination
->interval
);
1507 ARR_SetSize(broadcasts
, 0);
1510 /* ================================================== */
1513 CNF_GetNTPPort(void)
1518 /* ================================================== */
1521 CNF_GetAcquisitionPort(void)
1523 return acquisition_port
;
1526 /* ================================================== */
1529 CNF_GetDriftFile(void)
1534 /* ================================================== */
1537 CNF_GetLogBanner(void)
1542 /* ================================================== */
1550 /* ================================================== */
1553 CNF_GetDumpDir(void)
1558 /* ================================================== */
1561 CNF_GetLogMeasurements(int *raw
)
1563 *raw
= raw_measurements
;
1564 return do_log_measurements
;
1567 /* ================================================== */
1570 CNF_GetLogStatistics(void)
1572 return do_log_statistics
;
1575 /* ================================================== */
1578 CNF_GetLogTracking(void)
1580 return do_log_tracking
;
1583 /* ================================================== */
1591 /* ================================================== */
1594 CNF_GetLogRefclocks(void)
1596 return do_log_refclocks
;
1599 /* ================================================== */
1602 CNF_GetLogTempComp(void)
1604 return do_log_tempcomp
;
1607 /* ================================================== */
1610 CNF_GetKeysFile(void)
1615 /* ================================================== */
1618 CNF_GetRtcAutotrim(void)
1620 return rtc_autotrim_threshold
;
1623 /* ================================================== */
1626 CNF_GetRtcFile(void)
1631 /* ================================================== */
1634 CNF_GetRtcDevice(void)
1639 /* ================================================== */
1642 CNF_GetMaxUpdateSkew(void)
1644 return max_update_skew
;
1647 /* ================================================== */
1650 CNF_GetMaxDrift(void)
1655 /* ================================================== */
1658 CNF_GetMaxClockError(void)
1660 return max_clock_error
;
1663 /* ================================================== */
1666 CNF_GetCorrectionTimeRatio(void)
1668 return correction_time_ratio
;
1671 /* ================================================== */
1674 CNF_GetMaxSlewRate(void)
1676 return max_slew_rate
;
1679 /* ================================================== */
1682 CNF_GetMaxDistance(void)
1684 return max_distance
;
1687 /* ================================================== */
1690 CNF_GetMaxJitter(void)
1695 /* ================================================== */
1698 CNF_GetReselectDistance(void)
1700 return reselect_distance
;
1703 /* ================================================== */
1706 CNF_GetStratumWeight(void)
1708 return stratum_weight
;
1711 /* ================================================== */
1714 CNF_GetCombineLimit(void)
1716 return combine_limit
;
1719 /* ================================================== */
1722 CNF_GetManualEnabled(void)
1724 return enable_manual
;
1727 /* ================================================== */
1730 CNF_GetCommandPort(void) {
1734 /* ================================================== */
1737 CNF_AllowLocalReference(int *stratum
, int *orphan
, double *distance
)
1740 *stratum
= local_stratum
;
1741 *orphan
= local_orphan
;
1742 *distance
= local_distance
;
1749 /* ================================================== */
1752 CNF_GetRtcOnUtc(void)
1757 /* ================================================== */
1760 CNF_GetRtcSync(void)
1765 /* ================================================== */
1768 CNF_GetMakeStep(int *limit
, double *threshold
)
1770 *limit
= make_step_limit
;
1771 *threshold
= make_step_threshold
;
1774 /* ================================================== */
1777 CNF_GetMaxChange(int *delay
, int *ignore
, double *offset
)
1779 *delay
= max_offset_delay
;
1780 *ignore
= max_offset_ignore
;
1781 *offset
= max_offset
;
1784 /* ================================================== */
1787 CNF_GetLogChange(void)
1789 return log_change_threshold
;
1792 /* ================================================== */
1795 CNF_GetMailOnChange(int *enabled
, double *threshold
, char **user
)
1797 if (mail_user_on_change
) {
1799 *threshold
= mail_change_threshold
;
1800 *user
= mail_user_on_change
;
1808 /* ================================================== */
1811 CNF_SetupAccessRestrictions(void)
1817 for (i
= 0; i
< ARR_GetSize(ntp_restrictions
); i
++) {
1818 node
= ARR_GetElement(ntp_restrictions
, i
);
1819 status
= NCR_AddAccessRestriction(&node
->ip
, node
->subnet_bits
, node
->allow
, node
->all
);
1821 LOG_FATAL("Bad subnet in %s/%d", UTI_IPToString(&node
->ip
), node
->subnet_bits
);
1825 for (i
= 0; i
< ARR_GetSize(cmd_restrictions
); i
++) {
1826 node
= ARR_GetElement(cmd_restrictions
, i
);
1827 status
= CAM_AddAccessRestriction(&node
->ip
, node
->subnet_bits
, node
->allow
, node
->all
);
1829 LOG_FATAL("Bad subnet in %s/%d", UTI_IPToString(&node
->ip
), node
->subnet_bits
);
1833 ARR_SetSize(ntp_restrictions
, 0);
1834 ARR_SetSize(cmd_restrictions
, 0);
1837 /* ================================================== */
1840 CNF_GetNoClientLog(void)
1842 return no_client_log
;
1845 /* ================================================== */
1848 CNF_GetClientLogLimit(void)
1850 return client_log_limit
;
1853 /* ================================================== */
1856 CNF_GetFallbackDrifts(int *min
, int *max
)
1858 *min
= fb_drift_min
;
1859 *max
= fb_drift_max
;
1862 /* ================================================== */
1865 CNF_GetBindAddress(int family
, IPAddr
*addr
)
1867 if (family
== IPADDR_INET4
)
1868 *addr
= bind_address4
;
1869 else if (family
== IPADDR_INET6
)
1870 *addr
= bind_address6
;
1872 addr
->family
= IPADDR_UNSPEC
;
1875 /* ================================================== */
1878 CNF_GetBindAcquisitionAddress(int family
, IPAddr
*addr
)
1880 if (family
== IPADDR_INET4
)
1881 *addr
= bind_acq_address4
;
1882 else if (family
== IPADDR_INET6
)
1883 *addr
= bind_acq_address6
;
1885 addr
->family
= IPADDR_UNSPEC
;
1888 /* ================================================== */
1891 CNF_GetBindCommandPath(void)
1893 return bind_cmd_path
;
1896 /* ================================================== */
1899 CNF_GetBindCommandAddress(int family
, IPAddr
*addr
)
1901 if (family
== IPADDR_INET4
)
1902 *addr
= bind_cmd_address4
;
1903 else if (family
== IPADDR_INET6
)
1904 *addr
= bind_cmd_address6
;
1906 addr
->family
= IPADDR_UNSPEC
;
1909 /* ================================================== */
1912 CNF_GetNtpSigndSocket(void)
1914 return ntp_signd_socket
;
1917 /* ================================================== */
1920 CNF_GetPidFile(void)
1925 /* ================================================== */
1928 CNF_GetLeapSecMode(void)
1930 return leapsec_mode
;
1933 /* ================================================== */
1936 CNF_GetLeapSecTimezone(void)
1941 /* ================================================== */
1944 CNF_GetSchedPriority(void)
1946 return sched_priority
;
1949 /* ================================================== */
1952 CNF_GetLockMemory(void)
1957 /* ================================================== */
1959 int CNF_GetNTPRateLimit(int *interval
, int *burst
, int *leak
)
1961 *interval
= ntp_ratelimit_interval
;
1962 *burst
= ntp_ratelimit_burst
;
1963 *leak
= ntp_ratelimit_leak
;
1964 return ntp_ratelimit_enabled
;
1967 /* ================================================== */
1969 int CNF_GetCommandRateLimit(int *interval
, int *burst
, int *leak
)
1971 *interval
= cmd_ratelimit_interval
;
1972 *burst
= cmd_ratelimit_burst
;
1973 *leak
= cmd_ratelimit_leak
;
1974 return cmd_ratelimit_enabled
;
1977 /* ================================================== */
1980 CNF_GetSmooth(double *max_freq
, double *max_wander
, int *leap_only
)
1982 *max_freq
= smooth_max_freq
;
1983 *max_wander
= smooth_max_wander
;
1984 *leap_only
= smooth_leap_only
;
1987 /* ================================================== */
1990 CNF_GetTempComp(char **file
, double *interval
, char **point_file
, double *T0
, double *k0
, double *k1
, double *k2
)
1992 *file
= tempcomp_sensor_file
;
1993 *point_file
= tempcomp_point_file
;
1994 *interval
= tempcomp_interval
;
2001 /* ================================================== */
2009 /* ================================================== */
2012 CNF_GetMaxSamples(void)
2017 /* ================================================== */
2020 CNF_GetMinSamples(void)
2025 /* ================================================== */
2028 CNF_GetMinSources(void)
2033 /* ================================================== */
2036 CNF_GetHwclockFile(void)
2038 return hwclock_file
;
2041 /* ================================================== */
2044 CNF_GetInitSources(void)
2046 return ARR_GetSize(init_sources
);
2049 /* ================================================== */
2052 CNF_GetInitStepThreshold(void)
2054 return init_slew_threshold
;
2057 /* ================================================== */
2060 CNF_GetHwTsInterface(unsigned int index
, CNF_HwTsInterface
**iface
)
2062 if (index
>= ARR_GetSize(hwts_interfaces
))
2065 *iface
= (CNF_HwTsInterface
*)ARR_GetElement(hwts_interfaces
, index
);
2069 /* ================================================== */
2072 CNF_GetNtsCacheDir(void)
2074 return nts_cachedir
;
2077 /* ================================================== */
2080 CNF_GetNtsServerCertFile(void)
2082 return nts_server_cert_file
;
2085 /* ================================================== */
2088 CNF_GetNtsServerKeyFile(void)
2090 return nts_server_key_file
;
2093 /* ================================================== */
2096 CNF_GetNtsServerPort(void)
2098 return nts_server_port
;
2101 /* ================================================== */
2104 CNF_GetNtsServerProcesses(void)
2106 return nts_server_processes
;
2109 /* ================================================== */
2112 CNF_GetNtsServerConnections(void)
2114 return nts_server_connections
;
2117 /* ================================================== */
2120 CNF_GetNtsRefresh(void)
2125 /* ================================================== */
2128 CNF_GetNtsRotate(void)
2133 /* ================================================== */
2136 CNF_GetNtsTrustedCertFile(void)
2138 return nts_trusted_cert_file
;
2141 /* ================================================== */
2144 CNF_GetNoSystemCert(void)
2146 return no_system_cert
;