From: Alan T. DeKok Date: Mon, 26 Jun 2017 14:39:31 +0000 (-0400) Subject: add unlang_compile_subsection X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=443e6f44988e2ff8e056f57f368549436b79db93;p=thirdparty%2Ffreeradius-server.git add unlang_compile_subsection needed by various proto_radius_foo processors --- diff --git a/src/include/modules.h b/src/include/modules.h index 28e31cbc6b8..91b1967a579 100644 --- a/src/include/modules.h +++ b/src/include/modules.h @@ -223,6 +223,7 @@ rlm_rcode_t unlang_interpret(REQUEST *request, CONF_SECTION *cs, rlm_rcode_t def rlm_rcode_t unlang_interpret_synchronous(REQUEST *request, CONF_SECTION *cs, rlm_rcode_t action); int unlang_compile(CONF_SECTION *cs, rlm_components_t component); +int unlang_compile_subsection(CONF_SECTION *server_cs, char const *name1, char const *name2, rlm_components_t component); /** A callback when the the timeout occurs * diff --git a/src/main/unlang_compile.c b/src/main/unlang_compile.c index 830432c1122..0584c911ee9 100644 --- a/src/main/unlang_compile.c +++ b/src/main/unlang_compile.c @@ -3043,3 +3043,32 @@ int unlang_compile(CONF_SECTION *cs, rlm_components_t component) dump_tree(c, c->debug_name); return 0; } + +/** Compile a named subsection + * + * @param server_cs the server CONF_SECTION + * @param name1 the first name of the subsection to compile + * @param name2 the second name of the subsection to compile. + * @param component the component to compile + * @return + * - <0 on error + * - 0 on section was not found + * - 1 on successfully compiled + * + */ +int unlang_compile_subsection(CONF_SECTION *server_cs, char const *name1, char const *name2, rlm_components_t component) +{ + CONF_SECTION *cs; + + cs = cf_section_find(server_cs, name1, name2); + if (!cs) return 0; + + cf_log_debug(cs, "Compiling policies - %s %s {...}", name1, name2); + + if (unlang_compile(cs, component) < 0) { + cf_log_err(cs, "Failed compiling '%s %s { ... }' section", name1, name2); + return -1; + } + + return 1; +}