CONF_ITEM *cf_reference_item(CONF_SECTION const *parentcs,
CONF_SECTION *outercs,
char const *ptr);
+bool cf_file_changed(CONF_SECTION *cs);
extern CONF_SECTION *root_config;
extern bool cf_new_escape;
return fp;
}
+/*
+ * Return 0 for keep going, 1 for stop.
+ */
+static int file_callback(UNUSED void *ctx, void *data)
+{
+ struct stat buf;
+ cf_file_t *file = data;
+
+ if (stat(file->filename, &buf) < 0) return 1;
+
+ /*
+ * The file changed, we'll need to re-read it.
+ */
+ if (buf.st_mtime != file->buf.st_mtime) return 1;
+
+ return 0;
+}
+
+
+/*
+ * See if any of the files have changed.
+ */
+bool cf_file_changed(CONF_SECTION *cs)
+{
+ int rcode;
+ CONF_DATA *cd;
+ CONF_SECTION *top;
+ rbtree_t *tree;
+
+ top = cf_top_section(cs);
+ cd = cf_data_find_internal(top, "filename", 0);
+ if (!cd) return true;
+
+ tree = cd->data;
+
+ rcode = rbtree_walk(tree, RBTREE_IN_ORDER, file_callback, cs);
+ if (rcode == 0) {
+ return false;
+ }
+
+ return true;
+}
+
static int _cf_section_free(CONF_SECTION *cs)
{
/*
CONF_SECTION *cs;
char buffer[1024];
- INFO("HUP - Re-reading configuration files");
+ if (!cf_file_changed(cs_cache->cs)) {
+ INFO("HUP - No files changed. Ignoring");
+ return;
+ }
cs = cf_section_alloc(NULL, "main", NULL);
if (!cs) return;
/* Read the configuration file */
snprintf(buffer, sizeof(buffer), "%.200s/%.50s.conf", radius_dir, main_config.name);
+
+ INFO("HUP - Re-reading configuration files");
if (cf_file_read(cs, buffer) < 0) {
ERROR("Failed to re-read or parse %s", buffer);
talloc_free(cs);