]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Allow policies by section
authorAlan T. DeKok <aland@freeradius.org>
Tue, 14 Jun 2011 06:10:28 +0000 (08:10 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 14 Jun 2011 06:10:28 +0000 (08:10 +0200)
authorize {
foo
}

will look for first:

policy {
foo.authorize {
...
}
}

and then

policy {
foo {
...
}
}

This allows section-specific overrides for policies and modules.

src/main/modcall.c

index c54d661085bebf762c0a42f75d02d7169685dcde..3f22f3cd9ea421d701e328526fb7647cae71b8af 100644 (file)
@@ -1838,10 +1838,22 @@ static modcallable *do_compile_modsingle(modcallable *parent,
                cs = cf_section_find("instantiate");
                if (cs) subcs = cf_section_sub_find_name2(cs, NULL,
                                                          modrefname);
-               if (!subcs) {
-                       cs = cf_section_find("policy");
-                       if (cs) subcs = cf_section_sub_find_name2(cs, NULL,
+               if (!subcs &&
+                   (cs = cf_section_find("policy")) != NULL) {
+                       char buffer[256];
+                       
+                       snprintf(buffer, sizeof(buffer), "%s.%s",
+                                modrefname, comp2str[component]);
+
+                       /*
+                        *      Prefer name.section, then name.
+                        */
+                       subcs = cf_section_sub_find_name2(cs, NULL,
+                                                         buffer);
+                       if (!subcs) {
+                               subcs = cf_section_sub_find_name2(cs, NULL,
                                                                  modrefname);
+                       }
                }
 
                /*