From: Alan T. DeKok Date: Wed, 25 May 2016 16:17:33 +0000 (-0400) Subject: make unlang_interpret() take a default action X-Git-Tag: branch_3_1_x~325 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65c65ac4dbbd6f46463565d9caba58cd24fb9c08;p=thirdparty%2Ffreeradius-server.git make unlang_interpret() take a default action which is used if there's no CONF_SECTION or compile unlang --- diff --git a/src/include/interpreter.h b/src/include/interpreter.h index 67ee433b3cc..bdd4b79fefc 100644 --- a/src/include/interpreter.h +++ b/src/include/interpreter.h @@ -132,7 +132,7 @@ static inline modcallable *mod_xlattocallable(modxlat *p) return (modcallable *)p; } -rlm_rcode_t unlang_interpret(REQUEST *request, CONF_SECTION *cs, rlm_components_t component); +rlm_rcode_t unlang_interpret(REQUEST *request, CONF_SECTION *cs, rlm_rcode_t action); #ifdef __cplusplus } diff --git a/src/main/interpreter.c b/src/main/interpreter.c index bccdbd5b923..a8b488fdd57 100644 --- a/src/main/interpreter.c +++ b/src/main/interpreter.c @@ -992,40 +992,25 @@ done: } -static int default_component_results[MOD_COUNT] = { - RLM_MODULE_REJECT, /* AUTH */ - RLM_MODULE_NOTFOUND, /* AUTZ */ - RLM_MODULE_NOOP, /* PREACCT */ - RLM_MODULE_NOOP, /* ACCT */ - RLM_MODULE_FAIL, /* SESS */ - RLM_MODULE_NOOP, /* PRE_PROXY */ - RLM_MODULE_NOOP, /* POST_PROXY */ - RLM_MODULE_NOOP /* POST_AUTH */ -#ifdef WITH_COA - , - RLM_MODULE_NOOP, /* RECV_COA_TYPE */ - RLM_MODULE_NOOP /* SEND_COA_TYPE */ -#endif -}; - - /** Call a module, iteratively, with a local stack, rather than recursively * * What did Paul Graham say about Lisp...? */ -rlm_rcode_t unlang_interpret(REQUEST *request, CONF_SECTION *cs, rlm_components_t component) +rlm_rcode_t unlang_interpret(REQUEST *request, CONF_SECTION *cs, rlm_rcode_t action) { int priority; rlm_rcode_t result; modcallable *c; unlang_stack_t stack; + if (!cs) return action; + c = cf_data_find(cs, "unlang"); - if (!c) return default_component_results[component]; + if (!c) return action; memset(&stack, 0, sizeof(stack)); - result = default_component_results[component]; + result = action; priority = 0; unlang_push(&stack, c, result, true); diff --git a/src/main/modules.c b/src/main/modules.c index 9d046bc04f4..fa3edf71df4 100644 --- a/src/main/modules.c +++ b/src/main/modules.c @@ -1828,6 +1828,23 @@ int modules_init(CONF_SECTION *root) } +static int default_component_results[MOD_COUNT] = { + RLM_MODULE_REJECT, /* AUTH */ + RLM_MODULE_NOTFOUND, /* AUTZ */ + RLM_MODULE_NOOP, /* PREACCT */ + RLM_MODULE_NOOP, /* ACCT */ + RLM_MODULE_FAIL, /* SESS */ + RLM_MODULE_NOOP, /* PRE_PROXY */ + RLM_MODULE_NOOP, /* POST_PROXY */ + RLM_MODULE_NOOP /* POST_AUTH */ +#ifdef WITH_COA + , + RLM_MODULE_NOOP, /* RECV_COA_TYPE */ + RLM_MODULE_NOOP /* SEND_COA_TYPE */ +#endif +}; + + static rlm_rcode_t indexed_modcall(rlm_components_t comp, int idx, REQUEST *request) { rlm_rcode_t rcode; @@ -1848,9 +1865,10 @@ static rlm_rcode_t indexed_modcall(rlm_components_t comp, int idx, REQUEST *requ cs = cf_section_sub_find(request->server_cs, section_type_value[comp].section); if (!cs) { - RDEBUG2("Empty %s section in virtual server \"%s\". Using default return values.", - section_type_value[comp].section, request->server); - goto call_unlang; + RDEBUG2("Empty %s section in virtual server \"%s\". Using default return value %s.", + section_type_value[comp].section, request->server, + fr_int2str(mod_rcode_table, default_component_results[comp], "")); + return default_component_results[comp]; } /* @@ -1887,14 +1905,13 @@ static rlm_rcode_t indexed_modcall(rlm_components_t comp, int idx, REQUEST *requ * Cache and restore these, as they're re-set when * looping back from inside a module like eap-gtc. */ -call_unlang: module = request->module; component = request->component; request->module = NULL; request->component = section_type_value[comp].section; - rcode = unlang_interpret(request, cs, comp); + rcode = unlang_interpret(request, cs, default_component_results[comp]); request->component = component; request->module = module;