]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
forbid duplicate policies. Fixes #2738
authorAlan T. DeKok <aland@freeradius.org>
Sat, 3 Aug 2019 13:24:29 +0000 (09:24 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 3 Aug 2019 13:24:50 +0000 (09:24 -0400)
src/lib/server/module.c

index 65b83f5e55d23fbcfef6383e9d25cd15a73edd9f..8ddecd7e0cebced06903c5c21b6e047ddb5e56f4 100644 (file)
@@ -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;
 }