]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add "fail = retry" and sanity check it in the parser
authorAlan T. DeKok <aland@freeradius.org>
Tue, 31 Aug 2021 15:01:46 +0000 (11:01 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 31 Aug 2021 16:21:50 +0000 (12:21 -0400)
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.

src/lib/unlang/compile.c
src/lib/unlang/unlang_priv.h

index 22fefae270801576777ef0dbfc659ce780a015c4..dc79b86a22b63d5574a5ac1c7f5918a0296b9207 100644 (file)
@@ -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;
 }
 
index 8302e44352ac853a836418124d5663046d21192b..33bb19276465b1a891f1255c27346c1e335e8d4f 100644 (file)
@@ -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