]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
set default module actions, too
authorAlan T. DeKok <aland@freeradius.org>
Mon, 30 Aug 2021 17:53:05 +0000 (13:53 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 30 Aug 2021 17:53:05 +0000 (13:53 -0400)
and do some minor cleanups and comments for action / retry
handling

src/lib/unlang/compile.c

index 964af1520763ae0d0b6b3cc36771765dd3ffea29..cc719640c68f02c3980ddca68d9f972bf619b095 100644 (file)
@@ -1101,6 +1101,13 @@ static void compile_action_defaults(unlang_t *c, unlang_compile_t *unlang_ctx)
 {
        int i;
 
+       /*
+        *      Note that we do NOT copy over the default retries, as
+        *      that would result in every subsection doing it's own
+        *      retries.  That is not what we want.  Instead, we want
+        *      the retries to apply only to the _current_ section.
+        */
+
        /*
         *      Children of "redundant" and "redundant-load-balance"
         *      have RETURN for all actions except fail.  But THEIR children are normal.
@@ -1130,7 +1137,7 @@ static void compile_action_defaults(unlang_t *c, unlang_compile_t *unlang_ctx)
         */
        for (i = 0; i < RLM_MODULE_NUMCODES; i++) {
                if (!c->actions.actions[i]) {
-                       c->actions.actions[i] = unlang_ctx->actions[0].actions[i];
+                       c->actions.actions[i] = unlang_ctx->actions->actions[i];
                }
        }
 }
@@ -1564,6 +1571,16 @@ static bool compile_retry_section(unlang_actions_t *actions, CONF_ITEM *ci)
                        cf_log_err(csi, "Invalid item '%s' in 'retry' configuration.", name);
                        return false;
                }
+
+               /*
+                *      Sanity check the values.  If IRT is zero, then
+                *      the rest MUST be zero.
+                */
+               if (!actions->retry.irt &&
+                   (actions->retry.mrt || actions->retry.mrc || actions->retry.mrd)) {
+                       cf_log_err(csi, "If 'initial_rtx_time' is zero, then the other fields MUST be zero");
+                       return false;
+               }
        }
 
        return true;
@@ -3576,10 +3593,19 @@ static unlang_t *compile_module(unlang_t *parent, unlang_compile_t *unlang_ctx,
        c->type = UNLANG_TYPE_MODULE;
 
        /*
-        *      Set the default actions, and then try to compile an action subsection.
+        *      Set the default actions for this module.
+        */
+       c->actions = inst->actions;
+
+       /*
+        *      Add in the default actions for this section.
         */
        compile_action_defaults(c, unlang_ctx);
 
+       /*
+        *      If a module reference is a section, then the section
+        *      should contain action over-rides.  We add those here.
+        */
        if (cf_item_is_section(ci)) {
                if (!unlang_compile_actions(&c->actions, cf_item_to_section(ci))) {
                        talloc_free(c);