From: Alan T. DeKok Date: Tue, 14 Jun 2011 06:10:28 +0000 (+0200) Subject: Allow policies by section X-Git-Tag: release_2_1_11~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c5e2960271eff1b449c809e9d84e89df54ec9fc;p=thirdparty%2Ffreeradius-server.git Allow policies by section authorize { foo } will look for first: policy { foo.authorize { ... } } and then policy { foo { ... } } This allows section-specific overrides for policies and modules. --- diff --git a/src/main/modcall.c b/src/main/modcall.c index c54d661085b..3f22f3cd9ea 100644 --- a/src/main/modcall.c +++ b/src/main/modcall.c @@ -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); + } } /*