From: Alan T. DeKok Date: Thu, 29 Jan 2026 18:58:20 +0000 (-0500) Subject: mark sections as parsed when they're parsed, and complain on -C X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8eadc00e1ec68a7f0716bab491b9750c4e3c2c39;p=thirdparty%2Ffreeradius-server.git mark sections as parsed when they're parsed, and complain on -C if we have "send FOO" or "recv BAR" which is unused, then that's an error when using -C. Otherwise, a warning message is produced. --- diff --git a/src/lib/server/cf_parse.c b/src/lib/server/cf_parse.c index 6c8cdc71d30..110b7ab2e14 100644 --- a/src/lib/server/cf_parse.c +++ b/src/lib/server/cf_parse.c @@ -1226,6 +1226,7 @@ int cf_section_parse(TALLOC_CTX *ctx, void *base, CONF_SECTION *cs) cf_log_debug(cs, "%.*s}", SECTION_SPACE(cs), parse_spaces); + cf_item_mark_parsed(cs); return 0; } diff --git a/src/lib/server/client.c b/src/lib/server/client.c index d1eac20cbd8..952adce70d9 100644 --- a/src/lib/server/client.c +++ b/src/lib/server/client.c @@ -584,6 +584,7 @@ fr_client_list_t *client_list_parse_section(CONF_SECTION *section, int proto, TL goto error; } + cf_item_mark_parsed(cs); } /* @@ -916,6 +917,7 @@ fr_client_t *client_afrom_cs(TALLOC_CTX *ctx, CONF_SECTION *cs, CONF_SECTION *se c->limit.idle_timeout = fr_time_delta_wrap(0); } + cf_item_mark_parsed(cs); return c; } diff --git a/src/lib/server/virtual_servers.c b/src/lib/server/virtual_servers.c index 617cc7eb4f3..c30cd11dde8 100644 --- a/src/lib/server/virtual_servers.c +++ b/src/lib/server/virtual_servers.c @@ -1379,6 +1379,50 @@ static int virtual_server_compile_sections(virtual_server_t *vs, tmpl_rules_t co return -1; } + if (!check_config && !DEBUG_ENABLED) return found; + + /* + * Check for 'send FOO' and 'recv BAR' which are unused. + */ + for (subcs = cf_section_first(server); + subcs != NULL; + subcs = cf_section_next(server, subcs)) { + char const *name, *name2; + + if (cf_item_is_parsed(subcs)) continue; + + name = cf_section_name1(subcs); + + /* + * Allow them to "comment out" an entire block by prefixing the name with "-", ala + * "-sql". + */ + if (*name == '-') continue; + + /* + * Local clients are parsed by the listener after the virtual server is bootstrapped. So + * we just ignore them here. + */ + if (strcmp(name, "client") == 0) continue; + + /* + * When checking the configuration, it is an error to have an unused "send FOO" or "recv + * BAR" section. + */ + if (check_config && ((strcmp(name, "recv") == 0) || (strcmp(name, "send") == 0))) { + cf_log_err(subcs, "Unused processing section %s ... {", name); + cf_log_err(subcs, "If this is intentional, please rename it to '-%s'", name); + return -1; + } + + name2 = cf_section_name2(subcs); + if (!name2) { + cf_log_warn(subcs, "Ignoring %s { - it is unused", name); + } else { + cf_log_warn(subcs, "Ignoring %s %s { - it is unused", name, name2); + } + } + return found; } @@ -1738,6 +1782,7 @@ static fr_dict_t const *virtual_server_local_dict(CONF_SECTION *server_cs, fr_di */ cf_data_remove(server_cs, fr_dict_t, "dict"); cf_data_add(server_cs, dict, "dict", false); + cf_item_mark_parsed(cs); return dict; } diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index 851fe14a35e..f03b9456a43 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -2233,6 +2233,7 @@ int unlang_compile(virtual_server_t const *vs, * section is freed. */ cf_data_add(cs, c, NULL, true); + cf_item_mark_parsed(cs); if (instruction) *instruction = c; return 0;