mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-05 08:55:07 -05:00
conf: don't load sourcedir during initstepslew and RTC init
If the reload sources command was received in the chronyd start-up
sequence with initstepslew and/or RTC init (-s option), the sources
loaded from sourcedirs caused a crash due to failed assertion after
adding sources specified in the config.
Ignore the reload sources command until chronyd enters the normal
operation mode.
Fixes: 519796de37 ("conf: add sourcedirs directive")
This commit is contained in:
11
conf.c
11
conf.c
@@ -298,6 +298,8 @@ static ARR_Instance ntp_sources;
|
||||
static ARR_Instance ntp_source_dirs;
|
||||
/* Array of uint32_t corresponding to ntp_sources (for sourcedirs reload) */
|
||||
static ARR_Instance ntp_source_ids;
|
||||
/* Flag indicating ntp_sources and ntp_source_ids are used for sourcedirs */
|
||||
static int conf_ntp_sources_added = 0;
|
||||
|
||||
/* Array of RefclockParameters */
|
||||
static ARR_Instance refclock_sources;
|
||||
@@ -1689,8 +1691,12 @@ reload_source_dirs(void)
|
||||
NSR_Status s;
|
||||
int d, pass;
|
||||
|
||||
/* Ignore reload command before adding configured sources */
|
||||
if (!conf_ntp_sources_added)
|
||||
return;
|
||||
|
||||
prev_size = ARR_GetSize(ntp_source_ids);
|
||||
if (prev_size > 0 && ARR_GetSize(ntp_sources) != prev_size)
|
||||
if (ARR_GetSize(ntp_sources) != prev_size)
|
||||
assert(0);
|
||||
|
||||
/* Save the current sources and their configuration IDs */
|
||||
@@ -1859,7 +1865,10 @@ CNF_AddSources(void)
|
||||
Free(source->params.name);
|
||||
}
|
||||
|
||||
/* The arrays will be used for sourcedir (re)loading */
|
||||
ARR_SetSize(ntp_sources, 0);
|
||||
ARR_SetSize(ntp_source_ids, 0);
|
||||
conf_ntp_sources_added = 1;
|
||||
|
||||
reload_source_dirs();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user