From: Alan T. DeKok Date: Sat, 3 Aug 2019 13:24:29 +0000 (-0400) Subject: forbid duplicate policies. Fixes #2738 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2509a10090456f32732b1d45f2eadcecfdfd3269;p=thirdparty%2Ffreeradius-server.git forbid duplicate policies. Fixes #2738 --- diff --git a/src/lib/server/module.c b/src/lib/server/module.c index 65b83f5e55d..8ddecd7e0ce 100644 --- a/src/lib/server/module.c +++ b/src/lib/server/module.c @@ -1803,5 +1803,37 @@ int modules_bootstrap(CONF_SECTION *root) return -1; } + /* + * Check for duplicate policies. They're treated as + * modules, so we might as well check them here. + */ + cs = cf_section_find(root, "policy", NULL); + if (cs) { + bool fail = false; + + /* + * Loop over the items in the 'instantiate' section. + */ + while ((ci = cf_item_next(cs, ci))) { + CONF_SECTION *subcs, *problemcs; + + /* + * Skip anything that isn't a section. + */ + if (!cf_item_is_section(ci)) continue; + + subcs = cf_item_to_section(ci); + problemcs = cf_section_find_next(cs, subcs, + cf_section_name1(subcs), CF_IDENT_ANY); + if (!problemcs) continue; + + cf_log_err(problemcs, "Duplicate policy '%s' is forbidden.", + cf_section_name1(subcs)); + fail = true; + } + + if (fail) return -1; + } + return 0; }