static int restarted = 0;
static int generate_command_key = 0;
-static char *rtc_device = "/dev/rtc";
+static char *rtc_device;
static int acquisition_port = -1;
static int ntp_port = 123;
static char *keys_file = NULL;
static int do_log_tempcomp = 0;
static int do_dump_on_exit = 0;
static int log_banner = 32;
-static char *logdir = ".";
-static char *dumpdir = ".";
+static char *logdir;
+static char *dumpdir;
static int enable_local=0;
static int local_stratum;
/* Filename to use for storing pid of running chronyd, to prevent multiple
* chronyds being started. */
-static char *pidfile = "/var/run/chronyd.pid";
+static char *pidfile;
/* Temperature sensor, update interval and compensation coefficients */
static char *tempcomp_file = NULL;
static char *leapsec_tz = NULL;
/* Name of the user to which will be dropped root privileges. */
-static char *user = DEFAULT_USER;
+static char *user;
typedef struct {
NTP_Source_Type type;
/* ================================================== */
void
-CNF_SetRestarted(int r)
+CNF_Initialise(int r)
{
restarted = r;
+
+ dumpdir = Strdup(".");
+ logdir = Strdup(".");
+ pidfile = Strdup("/var/run/chronyd.pid");
+ rtc_device = Strdup("/dev/rtc");
+ user = Strdup(DEFAULT_USER);
+}
+
+/* ================================================== */
+
+void
+CNF_Finalise(void)
+{
+ unsigned int i;
+
+ for (i = 0; i < n_ntp_sources; i++)
+ Free(ntp_sources[i].params.name);
+
+ Free(drift_file);
+ Free(dumpdir);
+ Free(hwclock_file);
+ Free(keys_file);
+ Free(leapsec_tz);
+ Free(logdir);
+ Free(pidfile);
+ Free(rtc_device);
+ Free(rtc_file);
+ Free(user);
+ Free(mail_user_on_change);
+ Free(tempcomp_file);
}
/* ================================================== */
parse_string(char *line, char **result)
{
check_number_of_args(line, 1);
+ Free(*result);
*result = Strdup(line);
return 1;
}
check_number_of_args(line, 2);
address = line;
line = CPS_SplitWord(line);
+ Free(mail_user_on_change);
if (sscanf(line, "%lf", &mail_change_threshold) == 1) {
mail_user_on_change = Strdup(address);
} else {
return;
}
+ Free(tempcomp_file);
tempcomp_file = Strdup(p);
}
void
LCL_Finalise(void)
{
+ while (change_list.next != &change_list)
+ LCL_RemoveParameterChangeHandler(change_list.next->handler,
+ change_list.next->anything);
+
+ while (dispersion_notify_list.next != &dispersion_notify_list)
+ LCL_RemoveDispersionNotifyHandler(dispersion_notify_list.next->handler,
+ dispersion_notify_list.next->anything);
}
/* ================================================== */
void
NSR_Finalise(void)
{
+ int i;
+ struct UnresolvedSource *us;
+
+ for (i = 0; i < N_RECORDS; i++) {
+ if (!records[i].remote_addr)
+ continue;
+ records[i].remote_addr = NULL;
+ NCR_DestroyInstance(records[i].data);
+ }
+
+ while (unresolved_sources) {
+ us = unresolved_sources;
+ unresolved_sources = us->next;
+ Free(us->name);
+ Free(us);
+ }
+
initialised = 0;
}