]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Have xlat push functions take a result_p
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 18 May 2025 21:16:05 +0000 (15:16 -0600)
committerNick Porter <nick@portercomputing.co.uk>
Wed, 18 Jun 2025 12:53:00 +0000 (13:53 +0100)
14 files changed:
src/lib/unlang/condition.c
src/lib/unlang/foreach.c
src/lib/unlang/module.c
src/lib/unlang/module.h
src/lib/unlang/transaction_priv.h
src/lib/unlang/xlat.c
src/lib/unlang/xlat.h
src/lib/unlang/xlat_builtin.c
src/lib/unlang/xlat_eval.c
src/lib/unlang/xlat_expr.c
src/lib/unlang/xlat_priv.h
src/lib/unlang/xlat_purify.c
src/lib/unlang/xlat_redundant.c
src/modules/rlm_sqlcounter/rlm_sqlcounter.c

index ea0a7b4bba140776ea99d0ef22d1fd477c909de9..596352e44569f8eadc8a806252601ae361df716b 100644 (file)
@@ -30,8 +30,7 @@ RCSID("$Id$")
 typedef struct {
        fr_value_box_list_t     out;                            //!< Head of the result of a nested
                                                                ///< expansion.
-       bool                    success;                        //!< If set, where to record the result
-                                                               ///< of the execution.
+       unlang_result_t         result;                         //!< Store the result of unlang expressions.
 } unlang_frame_state_cond_t;
 
 static unlang_action_t unlang_if_resume(unlang_result_t *p_result, request_t *request, unlang_stack_frame_t *frame)
@@ -107,7 +106,7 @@ static unlang_action_t unlang_if(unlang_result_t *p_result, request_t *request,
 
        fr_value_box_list_init(&state->out);
 
-       if (unlang_xlat_push(state, &state->success, &state->out,
+       if (unlang_xlat_push(state, &state->result, &state->out,
                             request, gext->head, UNLANG_SUB_FRAME) < 0) return UNLANG_ACTION_FAIL;
 
        return UNLANG_ACTION_PUSHED_CHILD;
index d299c744732bb14a62d6557ffdb6e728c78dfb5f..5872b407ede65222c670772bb8fe030f3b52ede1 100644 (file)
@@ -49,7 +49,7 @@ typedef struct {
        uint32_t                index;                          //!< for xlat results
        char                    *buffer;                        //!< for key values
 
-       bool                    success;                        //!< for xlat expansion
+       unlang_result_t         exp_result;                     //!< for xlat expansion
        fr_value_box_list_t     list;                           //!< value box list for looping over xlats
 
        tmpl_dcursor_ctx_t      cc;                             //!< tmpl cursor state
@@ -209,7 +209,7 @@ static unlang_action_t unlang_foreach_xlat_expanded(unlang_result_t *p_result, r
        unlang_frame_state_foreach_t    *state = talloc_get_type_abort(frame->state, unlang_frame_state_foreach_t);
        fr_value_box_t *box;
 
-       if (!state->success) {
+       if (!XLAT_RESULT_SUCCESS(&state->exp_result)) {
                RDEBUG("Failed expanding 'foreach' list");
                RETURN_UNLANG_FAIL;
        }
@@ -248,7 +248,7 @@ static unlang_action_t unlang_foreach_xlat_init(unlang_result_t *p_result, reque
 {
        fr_value_box_list_init(&state->list);
 
-       if (unlang_xlat_push(state, &state->success, &state->list, request, tmpl_xlat(state->vpt), false) < 0) {
+       if (unlang_xlat_push(state, &state->exp_result, &state->list, request, tmpl_xlat(state->vpt), false) < 0) {
                REDEBUG("Failed starting expansion of %s", state->vpt->name);
                RETURN_UNLANG_FAIL;
        }
index 78593070ab1396116d91593d6e8028b113156ad3..b0356d42ab3529db968384fd689dbfbb8ee5f5d5 100644 (file)
@@ -164,7 +164,7 @@ int unlang_module_set_resume(request_t *request, module_method_t resume)
  * will then call the module resumption frame, allowing the module to continue execution.
  *
  * @param[in] ctx              To allocate talloc value boxes and values in.
- * @param[out] p_success       Whether xlat evaluation was successful.
+ * @param[out] p_result                Whether xlat evaluation was successful.
  * @param[out] out             Where to write the result of the expansion.
  * @param[in] request          The current request.
  * @param[in] exp              XLAT expansion to evaluate.
@@ -175,7 +175,7 @@ int unlang_module_set_resume(request_t *request, module_method_t resume)
  * @return
  *     - UNLANG_ACTION_PUSHED_CHILD
  */
-unlang_action_t unlang_module_yield_to_xlat(TALLOC_CTX *ctx, bool *p_success, fr_value_box_list_t *out,
+unlang_action_t unlang_module_yield_to_xlat(TALLOC_CTX *ctx, unlang_result_t *p_result, fr_value_box_list_t *out,
                                            request_t *request, xlat_exp_head_t const *exp,
                                            module_method_t resume,
                                            unlang_module_signal_t signal, fr_signal_t sigmask, void *rctx)
@@ -189,7 +189,7 @@ unlang_action_t unlang_module_yield_to_xlat(TALLOC_CTX *ctx, bool *p_success, fr
        /*
         *      Push the xlat function
         */
-       if (unlang_xlat_push(ctx, p_success, out, request, exp, false) < 0) return UNLANG_ACTION_STOP_PROCESSING;
+       if (unlang_xlat_push(ctx, p_result, out, request, exp, false) < 0) return UNLANG_ACTION_STOP_PROCESSING;
 
        return UNLANG_ACTION_PUSHED_CHILD;
 }
index 5cc105e33051f405db67d65058e8c568f9278b27..bf4ddb3aa7fde6807d6c7f233c27f3ee739516bb 100644 (file)
@@ -92,7 +92,7 @@ unlang_action_t       unlang_module_yield_to_section(unlang_result_t *p_result,
                                               module_method_t resume,
                                               unlang_module_signal_t signal, fr_signal_t sigmask, void *rctx);
 
-unlang_action_t        unlang_module_yield_to_xlat(TALLOC_CTX *ctx, bool *p_success, fr_value_box_list_t *out,
+unlang_action_t        unlang_module_yield_to_xlat(TALLOC_CTX *ctx, unlang_result_t *p_result, fr_value_box_list_t *out,
                                            request_t *request, xlat_exp_head_t const *xlat,
                                            module_method_t resume,
                                            unlang_module_signal_t signal, fr_signal_t sigmask, void *rctx);
index 315ca349969bbd2dd76ac1edaefc9dc44b641d88..9babcdb29bf12a90920a2d09cbeaed89ac7c17e3 100644 (file)
@@ -38,6 +38,7 @@ typedef struct {
  */
 typedef struct {
        fr_edit_list_t          *el;            //!< my edit list
+       unlang_result_t         result;
 } unlang_frame_state_transaction_t;
 
 /** Cast a group structure to the transaction keyword extension
index 68819f9f5c70b7814b61cf8899d341f7903712d2..a90773df51b5a15d578ad6dadb3c2c227bdb70a3 100644 (file)
@@ -28,6 +28,7 @@ RCSID("$Id$")
 #include <freeradius-devel/server/base.h>
 
 #include <ctype.h>
+#include <freeradius-devel/unlang/mod_action.h>
 #include <freeradius-devel/unlang/xlat_priv.h>
 #include <freeradius-devel/util/debug.h>
 #include "unlang_priv.h"       /* Fixme - Should create a proper semi-public interface for the interpret */
@@ -56,7 +57,7 @@ typedef struct {
        fr_signal_t             sigmask;                        //!< Signals to block
        void                    *rctx;                          //!< for resume / signal
 
-       bool                    *success;                       //!< If set, where to record the result
+       unlang_result_t         *p_result;                      //!< If set, where to record the result
                                                                ///< of the execution.
 } unlang_frame_state_xlat_t;
 
@@ -185,8 +186,8 @@ int unlang_xlat_timeout_add(request_t *request,
 /** Push a pre-compiled xlat onto the stack for evaluation
  *
  * @param[in] ctx              To allocate value boxes and values in.
- * @param[out] p_success       If set, and execution succeeds, true will be written
- *                             here.  If execution fails, false will be written.
+ * @param[out] p_result                If set, rcodes and priorities will be written here and
+ *                             not evaluated by the unlang interpreter.
  * @param[out] out             Where to write the result of the expansion.
  * @param[in] request          to push xlat onto.
  * @param[in] xlat             head of list
@@ -197,7 +198,7 @@ int unlang_xlat_timeout_add(request_t *request,
  *     - 0 on success.
  *     - -1 on failure.
  */
-static int unlang_xlat_push_internal(TALLOC_CTX *ctx, bool *p_success, fr_value_box_list_t *out,
+static int unlang_xlat_push_internal(TALLOC_CTX *ctx, unlang_result_t *p_result, fr_value_box_list_t *out,
                                     request_t *request, xlat_exp_head_t const *xlat, xlat_exp_t *node, bool top_frame)
 {
        /** Static instruction for performing xlat evaluations
@@ -230,7 +231,7 @@ static int unlang_xlat_push_internal(TALLOC_CTX *ctx, bool *p_success, fr_value_
        /*
         *      Push a new xlat eval frame onto the stack
         */
-       if (unlang_interpret_push(NULL, request, &xlat_instruction,
+       if (unlang_interpret_push(p_result, request, &xlat_instruction,
                                  FRAME_CONF(RLM_MODULE_NOT_SET, top_frame), UNLANG_NEXT_STOP) < 0) return -1;
        frame = &stack->frame[stack->depth];
 
@@ -240,7 +241,7 @@ static int unlang_xlat_push_internal(TALLOC_CTX *ctx, bool *p_success, fr_value_
        MEM(frame->state = state = talloc_zero(stack, unlang_frame_state_xlat_t));
        state->head = xlat;
        state->exp = node;
-       state->success = p_success;
+       state->p_result = p_result;
        state->ctx = ctx;
 
        if (node) switch (node->type) {
@@ -269,8 +270,6 @@ static int unlang_xlat_push_internal(TALLOC_CTX *ctx, bool *p_success, fr_value_
 /** Push a pre-compiled xlat onto the stack for evaluation
  *
  * @param[in] ctx              To allocate value boxes and values in.
- * @param[out] p_success       If set, and execution succeeds, true will be written
- *                             here.  If execution fails, false will be written.
  * @param[out] out             Where to write the result of the expansion.
  * @param[in] request          to push xlat onto.
  * @param[in] xlat             to evaluate.
@@ -280,18 +279,18 @@ static int unlang_xlat_push_internal(TALLOC_CTX *ctx, bool *p_success, fr_value_
  *     - 0 on success.
  *     - -1 on failure.
  */
-int unlang_xlat_push(TALLOC_CTX *ctx, bool *p_success, fr_value_box_list_t *out,
+int unlang_xlat_push(TALLOC_CTX *ctx, unlang_result_t *p_result, fr_value_box_list_t *out,
                     request_t *request, xlat_exp_head_t const *xlat, bool top_frame)
 {
        (void) talloc_get_type_abort_const(xlat, xlat_exp_head_t);
 
-       return unlang_xlat_push_internal(ctx, p_success, out, request, xlat, xlat_exp_head(xlat), top_frame);
+       return unlang_xlat_push_internal(ctx, p_result, out, request, xlat, xlat_exp_head(xlat), top_frame);
 }
 
 /** Push a pre-compiled xlat onto the stack for evaluation
  *
  * @param[in] ctx              To allocate value boxes and values in.
- * @param[out] p_success       If set, and execution succeeds, true will be written
+ * @param[out] p_result                If set, and execution succeeds, true will be written
  *                             here.  If execution fails, false will be written.
  * @param[out] out             Where to write the result of the expansion.
  * @param[in] request          to push xlat onto.
@@ -300,10 +299,10 @@ int unlang_xlat_push(TALLOC_CTX *ctx, bool *p_success, fr_value_box_list_t *out,
  *     - 0 on success.
  *     - -1 on failure.
  */
-int unlang_xlat_push_node(TALLOC_CTX *ctx, bool *p_success, fr_value_box_list_t *out,
+int unlang_xlat_push_node(TALLOC_CTX *ctx, unlang_result_t *p_result, fr_value_box_list_t *out,
                          request_t *request, xlat_exp_t *node)
 {
-       return unlang_xlat_push_internal(ctx, p_success, out, request, NULL, node, UNLANG_TOP_FRAME);
+       return unlang_xlat_push_internal(ctx, p_result, out, request, NULL, node, UNLANG_TOP_FRAME);
 }
 
 static unlang_action_t unlang_xlat_repeat(unlang_result_t *p_result, request_t *request, unlang_stack_frame_t *frame)
@@ -345,7 +344,7 @@ static unlang_action_t unlang_xlat_repeat(unlang_result_t *p_result, request_t *
                 *      multiple sibling nodes.
                 */
                fr_value_box_list_talloc_free(&state->out);
-               if (unlang_xlat_push(state->ctx, state->success, &state->out, request, child, false) < 0) {
+               if (unlang_xlat_push(state->ctx, p_result, &state->out, request, child, false) < 0) {
                        REXDENT();
                        return UNLANG_ACTION_STOP_PROCESSING;
                }
@@ -364,14 +363,12 @@ static unlang_action_t unlang_xlat_repeat(unlang_result_t *p_result, request_t *
                return UNLANG_ACTION_YIELD;
 
        case XLAT_ACTION_DONE:
-               if (state->success) *state->success = true;
                p_result->rcode = RLM_MODULE_OK;
                REXDENT();
                return UNLANG_ACTION_CALCULATE_RESULT;
 
        case XLAT_ACTION_FAIL:
        fail:
-               if (state->success) *state->success = false;
                p_result->rcode = RLM_MODULE_FAIL;
                REXDENT();
                return UNLANG_ACTION_CALCULATE_RESULT;
@@ -387,7 +384,7 @@ static unlang_action_t unlang_xlat_repeat(unlang_result_t *p_result, request_t *
  * Calls the xlat interpreter and translates its wants and needs into
  * unlang_action_t codes.
  */
-static unlang_action_t unlang_xlat(unlang_result_t *p_result, request_t *request, unlang_stack_frame_t *frame)
+static unlang_action_t unlang_xlat(UNUSED unlang_result_t *p_result, request_t *request, unlang_stack_frame_t *frame)
 {
        unlang_frame_state_xlat_t       *state = talloc_get_type_abort(frame->state, unlang_frame_state_xlat_t);
        xlat_action_t                   xa;
@@ -409,7 +406,7 @@ static unlang_action_t unlang_xlat(unlang_result_t *p_result, request_t *request
                 *      multiple sibling nodes.
                 */
                fr_value_box_list_talloc_free(&state->out);
-               if (unlang_xlat_push(state->ctx, state->success, &state->out, request, child, false) < 0) {
+               if (unlang_xlat_push(state->ctx, NULL, &state->out, request, child, false) < 0) {
                        RINDENT_RESTORE(request, state);
                        return UNLANG_ACTION_STOP_PROCESSING;
                }
@@ -428,14 +425,12 @@ static unlang_action_t unlang_xlat(unlang_result_t *p_result, request_t *request
                return UNLANG_ACTION_YIELD;
 
        case XLAT_ACTION_DONE:
-               if (state->success) *state->success = true;
                p_result->rcode = RLM_MODULE_OK;
                RINDENT_RESTORE(request, state);
                return UNLANG_ACTION_CALCULATE_RESULT;
 
        case XLAT_ACTION_FAIL:
        fail:
-               if (state->success) *state->success = false;
                p_result->rcode = RLM_MODULE_FAIL;
                RINDENT_RESTORE(request, state);
                return UNLANG_ACTION_CALCULATE_RESULT;
@@ -506,7 +501,6 @@ static unlang_action_t unlang_xlat_resume(unlang_result_t *p_result, request_t *
                return UNLANG_ACTION_YIELD;
 
        case XLAT_ACTION_DONE:
-               if (state->success) *state->success = true;
                p_result->rcode = RLM_MODULE_OK;
                RINDENT_RESTORE(request, state);
                return UNLANG_ACTION_CALCULATE_RESULT;
@@ -526,14 +520,13 @@ static unlang_action_t unlang_xlat_resume(unlang_result_t *p_result, request_t *
                 *      multiple sibling nodes.
                 */
                fr_value_box_list_talloc_free(&state->out);
-               if (unlang_xlat_push(state->ctx, state->success, &state->out, request, child, false) < 0) {
+               if (unlang_xlat_push(state->ctx, state->p_result, &state->out, request, child, false) < 0) {
                        RINDENT_RESTORE(request, state);
                        return UNLANG_ACTION_STOP_PROCESSING;
                }
                return UNLANG_ACTION_PUSHED_CHILD;
 
        case XLAT_ACTION_FAIL:
-               if (state->success) *state->success = false;
                p_result->rcode = RLM_MODULE_FAIL;
                RINDENT_RESTORE(request, state);
                return UNLANG_ACTION_CALCULATE_RESULT;
@@ -734,18 +727,18 @@ xlat_action_t unlang_xlat_yield_to_retry(request_t *request, xlat_func_t resume,
  */
 int unlang_xlat_eval(TALLOC_CTX *ctx, fr_value_box_list_t *out, request_t *request, xlat_exp_head_t const *xlat)
 {
-       bool    success = false;
+       unlang_result_t result = { .rcode = RLM_MODULE_NOT_SET, .priority = MOD_ACTION_NOT_SET };
 
        if (xlat->flags.impure_func) {
                fr_strerror_const("Expansion requires async operations");
                return -1;
        }
 
-       if (unlang_xlat_push(ctx, &success, out, request, xlat, UNLANG_TOP_FRAME) < 0) return -1;
+       if (unlang_xlat_push(ctx, &result, out, request, xlat, UNLANG_TOP_FRAME) < 0) return -1;
 
        (void) unlang_interpret(request, UNLANG_REQUEST_RUNNING);
 
-       if (!success) return -1;
+       if (!XLAT_RESULT_SUCCESS(&result)) return -1;
 
        return 0;
 }
index d4dc26606ad199191b794b52f2277e25fb6c5200..6eaa613fc9694ec5fda12dc74d47aea1571659a3 100644 (file)
@@ -63,6 +63,7 @@ typedef ssize_t (*xlat_escape_legacy_t)(request_t *request, char *out, size_t ou
 
 #include <freeradius-devel/unlang/call_env.h>
 #include <freeradius-devel/unlang/xlat_ctx.h>
+#include <freeradius-devel/unlang/interpret.h>
 
 /** Instance data for an xlat expansion node
  *
@@ -499,7 +500,9 @@ int         xlat_purify_op(TALLOC_CTX *ctx, xlat_exp_t **out, xlat_exp_t *lhs, fr_token
 int            unlang_xlat_timeout_add(request_t *request, fr_unlang_xlat_timeout_t callback,
                                        void const *rctx, fr_time_t when);
 
-int            unlang_xlat_push(TALLOC_CTX *ctx, bool *p_success, fr_value_box_list_t *out,
+#define XLAT_RESULT_SUCCESS(_p_result) ((_p_result)->rcode == RLM_MODULE_OK)
+
+int            unlang_xlat_push(TALLOC_CTX *ctx, unlang_result_t *p_result, fr_value_box_list_t *out,
                                 request_t *request, xlat_exp_head_t const *head, bool top_frame)
                                 CC_HINT(warn_unused_result);
 
index 8ee093a51660228a15d7277824326d5d1e1dd321..fcd6601476151b8f5eb7052a2e7e101a8b226266 100644 (file)
@@ -1391,7 +1391,7 @@ static xlat_action_t xlat_func_next_time(TALLOC_CTX *ctx, fr_dcursor_t *out,
 }
 
 typedef struct {
-       bool            last_success;
+       unlang_result_t last_result;
        xlat_exp_head_t *ex;
 } xlat_eval_rctx_t;
 
@@ -1403,7 +1403,7 @@ static xlat_action_t xlat_eval_resume(UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_
                                      UNUSED request_t *request, UNUSED fr_value_box_list_t *in)
 {
        xlat_eval_rctx_t        *rctx = talloc_get_type_abort(xctx->rctx, xlat_eval_rctx_t);
-       xlat_action_t           xa = rctx->last_success ? XLAT_ACTION_DONE : XLAT_ACTION_FAIL;
+       xlat_action_t           xa = XLAT_RESULT_SUCCESS(&rctx->last_result) ? XLAT_ACTION_DONE : XLAT_ACTION_FAIL;
 
        talloc_free(rctx);
 
@@ -1491,7 +1491,7 @@ static xlat_action_t xlat_func_eval(TALLOC_CTX *ctx, fr_dcursor_t *out,
 
        if (unlang_xlat_yield(request, xlat_eval_resume, NULL, 0, rctx) != XLAT_ACTION_YIELD) goto error;
 
-       if (unlang_xlat_push(ctx, &rctx->last_success, (fr_value_box_list_t *)out->dlist,
+       if (unlang_xlat_push(ctx, &rctx->last_result, (fr_value_box_list_t *)out->dlist,
                             request, rctx->ex, UNLANG_SUB_FRAME) < 0) goto error;
 
        return XLAT_ACTION_PUSH_UNLANG;
index 842938dbc8db487da2cda6a198d6085ff7d5829c..720e6cab355e08eacb5ef2340c43d6119bd11ecb 100644 (file)
@@ -28,6 +28,8 @@ RCSID("$Id$")
 
 #include <freeradius-devel/server/base.h>
 #include <freeradius-devel/server/tmpl_dcursor.h>
+#include <freeradius-devel/server/rcode.h>
+#include <freeradius-devel/unlang/mod_action.h>
 #include <freeradius-devel/unlang/xlat_priv.h>
 
 static int instance_count = 0;
@@ -1622,7 +1624,7 @@ static ssize_t xlat_eval_sync(TALLOC_CTX *ctx, char **out, request_t *request, x
                              xlat_escape_legacy_t escape, void const *escape_ctx)
 {
        fr_value_box_list_t     result;
-       bool                    success = false;
+       unlang_result_t         unlang_result = { .rcode = RLM_MODULE_NOT_SET, .priority = MOD_ACTION_NOT_SET };
        TALLOC_CTX              *pool = talloc_new(NULL);
        rlm_rcode_t             rcode;
        char                    *str;
@@ -1636,7 +1638,7 @@ static ssize_t xlat_eval_sync(TALLOC_CTX *ctx, char **out, request_t *request, x
        /*
         *      Use the unlang stack to evaluate the xlat.
         */
-       if (unlang_xlat_push(pool, &success, &result, request, head, UNLANG_TOP_FRAME) < 0) {
+       if (unlang_xlat_push(pool, &unlang_result, &result, request, head, UNLANG_TOP_FRAME) < 0) {
        fail:
                talloc_free(pool);
                return -1;
@@ -1655,7 +1657,7 @@ static ssize_t xlat_eval_sync(TALLOC_CTX *ctx, char **out, request_t *request, x
 
        switch (rcode) {
        default:
-               if (!success) goto fail;
+               if (!XLAT_RESULT_SUCCESS(&unlang_result)) goto fail;
                break;
 
        case RLM_MODULE_REJECT:
index 43cae3aea08cdd071eca94f59bbe1a1d1aa2848b..d9d326329cbdb23a8067b2161c861eb02a77b191 100644 (file)
@@ -514,7 +514,7 @@ typedef struct {
 } xlat_regex_inst_t;
 
 typedef struct {
-       bool                    last_success;
+       unlang_result_t         last_result;
        fr_value_box_list_t     list;
 } xlat_regex_rctx_t;
 
@@ -764,7 +764,7 @@ static xlat_action_t xlat_regex_resume(TALLOC_CTX *ctx, fr_dcursor_t *out,
        /*
         *      If the expansions fails, then we fail the entire thing.
         */
-       if (!rctx->last_success) {
+       if (!XLAT_RESULT_SUCCESS(&rctx->last_result)) {
                talloc_free(rctx);
                return XLAT_ACTION_FAIL;
        }
@@ -816,7 +816,7 @@ static xlat_action_t xlat_regex_op(TALLOC_CTX *ctx, fr_dcursor_t *out,
                return XLAT_ACTION_FAIL;
        }
 
-       if (unlang_xlat_push(ctx, &rctx->last_success, &rctx->list,
+       if (unlang_xlat_push(ctx, &rctx->last_result, &rctx->list,
                             request, tmpl_xlat(inst->xlat->vpt), UNLANG_SUB_FRAME) < 0) goto fail;
 
        return XLAT_ACTION_PUSH_UNLANG;
@@ -871,7 +871,7 @@ typedef struct {
 
 typedef struct {
        TALLOC_CTX              *ctx;
-       bool                    last_success;
+       unlang_result_t         last_result;
        fr_value_box_t          *box;           //!< output value-box
        int                     current;
        fr_value_box_list_t     list;
@@ -1143,7 +1143,7 @@ static xlat_action_t xlat_logical_process_arg(UNUSED TALLOC_CTX *ctx, UNUSED fr_
                return XLAT_ACTION_FAIL;
        }
 
-       if (unlang_xlat_push(rctx, &rctx->last_success, &rctx->list,
+       if (unlang_xlat_push(rctx, &rctx->last_result, &rctx->list,
                             request, inst->argv[rctx->current], UNLANG_SUB_FRAME) < 0) goto fail;
 
        return XLAT_ACTION_PUSH_UNLANG;
index ff1c3a1973bf0956c00eaee46641c32f67d177fc..9fca229d10dd70465e0f19ba47600852e4cce108 100644 (file)
@@ -334,7 +334,7 @@ void                xlat_eval_free(void);
 
 void           unlang_xlat_init(void);
 
-int            unlang_xlat_push_node(TALLOC_CTX *ctx, bool *p_success, fr_value_box_list_t *out,
+int            unlang_xlat_push_node(TALLOC_CTX *ctx, unlang_result_t *p_result, fr_value_box_list_t *out,
                                      request_t *request, xlat_exp_t *node);
 
 int            xlat_decode_value_box_list(TALLOC_CTX *ctx, fr_pair_list_t *out,
index 472aa05d4f12d704f2b2aaf36f88fedec615e798..58db33a9fb8b8313e88583e047854ba36e8cd4ea 100644 (file)
@@ -27,6 +27,7 @@
 RCSID("$Id$")
 
 #include <freeradius-devel/server/base.h>
+#include <freeradius-devel/unlang/mod_action.h>
 #include <freeradius-devel/unlang/xlat_priv.h>
 #include <freeradius-devel/util/calc.h>
 
@@ -65,7 +66,7 @@ int xlat_purify_list(xlat_exp_head_t *head, request_t *request)
 static int xlat_purify_list_internal(xlat_exp_head_t *head, request_t *request, fr_token_t quote)
 {
        int rcode;
-       bool success;
+       unlang_result_t result = { .rcode = RLM_MODULE_NOT_SET, .priority = MOD_ACTION_NOT_SET };
        fr_value_box_list_t list;
        xlat_flags_t our_flags;
        xlat_exp_t *node, *next;
@@ -254,8 +255,8 @@ static int xlat_purify_list_internal(xlat_exp_head_t *head, request_t *request,
                         */
                        fr_assert(node->flags.pure);
                        fr_value_box_list_init(&list);
-                       success = false;
-                       if (unlang_xlat_push_node(head, &success, &list, request, node) < 0) {
+                       result.rcode = RLM_MODULE_NOT_SET;
+                       if (unlang_xlat_push_node(head, &result, &list, request, node) < 0) {
                                return -1;
                        }
 
@@ -264,7 +265,7 @@ static int xlat_purify_list_internal(xlat_exp_head_t *head, request_t *request,
                         */
 
                        (void) unlang_interpret_synchronous(NULL, request);
-                       if (!success) return -1;
+                       if (!XLAT_RESULT_SUCCESS(&result)) return -1;
 
                        /*
                         *      The function call becomes a GROUP of boxes
index 391fd89ac01d712c6fbaae42cf0f285c67ec5cdc..c171c5e99c8f9ec2507c2a974b1a4b89f65ab1d6 100644 (file)
@@ -72,7 +72,7 @@ typedef struct {
 } xlat_redundant_inst_t;
 
 typedef struct {
-       bool                            last_success;   //!< Did the last call succeed?
+       unlang_result_t                 last_result;    //!< Did the last call succeed?
 
        xlat_exp_head_t                 **first;        //!< First function called.
                                                        ///< Used for redundant-load-balance.
@@ -90,7 +90,7 @@ static xlat_action_t xlat_redundant_resume(TALLOC_CTX *ctx, fr_dcursor_t *out,
        xlat_redundant_rctx_t           *rctx = talloc_get_type_abort(xctx->rctx, xlat_redundant_rctx_t);
        xlat_action_t                   xa = XLAT_ACTION_DONE;
 
-       if (rctx->last_success) {
+       if (XLAT_RESULT_SUCCESS(&rctx->last_result)) {
        done:
                talloc_free(rctx);
                return xa;
@@ -115,7 +115,7 @@ static xlat_action_t xlat_redundant_resume(TALLOC_CTX *ctx, fr_dcursor_t *out,
        /*
         *      Push the next child...
         */
-       if (unlang_xlat_push(ctx, &rctx->last_success, (fr_value_box_list_t *)out->dlist,
+       if (unlang_xlat_push(ctx, &rctx->last_result, (fr_value_box_list_t *)out->dlist,
                             request, *rctx->current, UNLANG_SUB_FRAME) < 0) goto error;
 
        return XLAT_ACTION_PUSH_UNLANG;
@@ -129,7 +129,7 @@ static xlat_action_t xlat_load_balance_resume(UNUSED TALLOC_CTX *ctx, UNUSED fr_
                                              UNUSED request_t *request, UNUSED fr_value_box_list_t *in)
 {
        xlat_redundant_rctx_t   *rctx = talloc_get_type_abort(xctx->rctx, xlat_redundant_rctx_t);
-       xlat_action_t           xa = rctx->last_success ? XLAT_ACTION_DONE : XLAT_ACTION_FAIL;
+       xlat_action_t           xa = XLAT_RESULT_SUCCESS(&rctx->last_result) ? XLAT_ACTION_DONE : XLAT_ACTION_FAIL;
 
        talloc_free(rctx);
 
@@ -184,7 +184,7 @@ static xlat_action_t xlat_redundant(TALLOC_CTX *ctx, fr_dcursor_t *out,
                fr_assert(0);
        }
 
-       if (unlang_xlat_push(ctx, &rctx->last_success, (fr_value_box_list_t *)out->dlist,
+       if (unlang_xlat_push(ctx, &rctx->last_result, (fr_value_box_list_t *)out->dlist,
                             request, *rctx->current, UNLANG_SUB_FRAME) < 0) return XLAT_ACTION_FAIL;
 
        return XLAT_ACTION_PUSH_UNLANG;
index 98b9f9d8651061ae7356dd3afcd7d8ae4d77494e..acd381390e68dddf3a076d06aa87cf270fe73a7a 100644 (file)
@@ -249,7 +249,7 @@ static int find_prev_reset(rlm_sqlcounter_t *inst, fr_time_t now)
 }
 
 typedef struct {
-       bool                    last_success;
+       unlang_result_t         last_result;
        fr_value_box_list_t     result;
        rlm_sqlcounter_t        *inst;
        sqlcounter_call_env_t   *env;
@@ -436,7 +436,7 @@ static unlang_action_t CC_HINT(nonnull) mod_authorize(rlm_rcode_t *p_result, mod
        }
 
        fr_value_box_list_init(&rctx->result);
-       if (unlang_xlat_push(rctx, &rctx->last_success, &rctx->result, request, env->query_xlat, UNLANG_SUB_FRAME) < 0) goto error;
+       if (unlang_xlat_push(rctx, &rctx->last_result, &rctx->result, request, env->query_xlat, UNLANG_SUB_FRAME) < 0) goto error;
 
        return UNLANG_ACTION_PUSHED_CHILD;
 }