From: Alan T. DeKok Date: Tue, 31 Aug 2021 15:01:46 +0000 (-0400) Subject: add "fail = retry" and sanity check it in the parser X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36b82d2041515c8748ecb46e68430ae3de7ae883;p=thirdparty%2Ffreeradius-server.git add "fail = retry" and sanity check it in the parser note that if we have a section which is doing retries, it can have "fail = retry". But its sub-sections cannot have "fail=retry" because that doesn't make much sense. --- diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index 22fefae2708..dc79b86a22b 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -1475,6 +1475,9 @@ static int compile_action_pair(unlang_actions_t *actions, CONF_PAIR *cp) else if (!strcasecmp(value, "reject")) action = MOD_ACTION_REJECT; + else if (!strcasecmp(value, "retry")) + action = MOD_ACTION_RETRY; + else if (strspn(value, "0123456789")==strlen(value)) { action = atoi(value); @@ -1589,6 +1592,7 @@ static bool compile_retry_section(unlang_actions_t *actions, CONF_ITEM *ci) bool unlang_compile_actions(unlang_actions_t *actions, CONF_SECTION *action_cs) { + int i; CONF_ITEM *csi; CONF_SECTION *cs; @@ -1646,6 +1650,20 @@ bool unlang_compile_actions(unlang_actions_t *actions, CONF_SECTION *action_cs) } } + /* + * Sanity check that "fail = retry", we actually have a + * retry section. + */ + for (i = 0; i < RLM_MODULE_NUMCODES; i++) { + if (actions->actions[i] != MOD_ACTION_RETRY) continue; + + if (!actions->retry.irt) { + cf_log_err(csi, "Cannot use a '%s = retry' action without a 'retry { ... }' section.", + fr_table_str_by_value(mod_rcode_table, i, "???")); + return false; + } + } + return true; } diff --git a/src/lib/unlang/unlang_priv.h b/src/lib/unlang/unlang_priv.h index 8302e44352a..33bb1927646 100644 --- a/src/lib/unlang/unlang_priv.h +++ b/src/lib/unlang/unlang_priv.h @@ -44,6 +44,7 @@ extern "C" { * to cause an immediate reject. */ #define MOD_ACTION_RETURN (-1) #define MOD_ACTION_REJECT (-2) +#define MOD_ACTION_RETRY (-3) #define MOD_PRIORITY_MAX (64) /** Types of unlang_t nodes