From: Alan T. DeKok Date: Wed, 25 Aug 2021 15:57:04 +0000 (-0400) Subject: change to passing CONF_SECTION, and publish it X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d45259a9080fc31f1e53b2adb0cbecdb92ee171f;p=thirdparty%2Ffreeradius-server.git change to passing CONF_SECTION, and publish it --- diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index e2c537bb135..ad7250ddb94 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -1569,17 +1569,15 @@ static bool compile_retry_section(unlang_actions_t *actions, CONF_ITEM *ci) return true; } -static bool compile_action_section(unlang_actions_t *actions, CONF_ITEM *ci) +bool unlang_compile_actions(unlang_actions_t *actions, CONF_SECTION *parent) { CONF_ITEM *csi; CONF_SECTION *cs; - if (!cf_item_is_section(ci)) return true; - /* * Over-ride the default return codes of the module. */ - cs = cf_item_to_section(ci); + cs = cf_item_to_section(cf_section_to_item(parent)); for (csi=cf_item_next(cs, NULL); csi != NULL; csi=cf_item_next(cs, csi)) { @@ -1615,7 +1613,7 @@ static bool compile_action_section(unlang_actions_t *actions, CONF_ITEM *ci) CONF_ITEM *subci; char const *value = cf_pair_value(cp); - subci = cf_reference_item(cs, cf_root(ci), value); + subci = cf_reference_item(cs, cf_root(cf_section_to_item(parent)), value); if (!subci) { cf_log_err(csi, "Unknown reference '%s'", value ? value : "???"); return false; @@ -1701,7 +1699,7 @@ static bool compile_action_subsection(unlang_t *c, CONF_SECTION *cs, CONF_SECTIO return false; } - return compile_action_section(&c->actions, ci); + return unlang_compile_actions(&c->actions, subcs); } @@ -3397,13 +3395,13 @@ static unlang_t *compile_function(unlang_t *parent, unlang_compile_t *unlang_ctx /* * Return the compiled thing if we can. */ - if (cf_item_is_pair(ci)) return c; + if (!cf_item_is_section(ci)) return c; /* * Else we have a reference to a policy, and that reference * over-rides the return codes for the policy! */ - if (!compile_action_section(&c->actions, ci)) { + if (!unlang_compile_actions(&c->actions, cf_item_to_section(ci))) { talloc_free(c); return NULL; } @@ -3581,9 +3579,12 @@ static unlang_t *compile_module(unlang_t *parent, unlang_compile_t *unlang_ctx, * Set the default actions, and then try to compile an action subsection. */ compile_action_defaults(c, unlang_ctx); - if (!compile_action_section(&c->actions, ci)) { - talloc_free(c); - return NULL; + + if (cf_item_is_section(ci)) { + if (!unlang_compile_actions(&c->actions, cf_item_to_section(ci))) { + talloc_free(c); + return NULL; + } } return c; diff --git a/src/lib/unlang/compile.h b/src/lib/unlang/compile.h index 035cdadd7cb..25995cf677c 100644 --- a/src/lib/unlang/compile.h +++ b/src/lib/unlang/compile.h @@ -42,6 +42,8 @@ int unlang_compile(CONF_SECTION *cs, rlm_components_t component, tmpl_rules_t c bool unlang_compile_is_keyword(const char *name); +bool unlang_compile_actions(unlang_actions_t *actions, CONF_SECTION *parent); + #ifdef __cplusplus } #endif