From: Arran Cudbard-Bell Date: Sun, 18 May 2025 21:16:05 +0000 (-0600) Subject: Have xlat push functions take a result_p X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e0521ce17f02b2c23269b6eeaae66583db2d3e7;p=thirdparty%2Ffreeradius-server.git Have xlat push functions take a result_p --- diff --git a/src/lib/unlang/condition.c b/src/lib/unlang/condition.c index ea0a7b4bba1..596352e4456 100644 --- a/src/lib/unlang/condition.c +++ b/src/lib/unlang/condition.c @@ -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; diff --git a/src/lib/unlang/foreach.c b/src/lib/unlang/foreach.c index d299c744732..5872b407ede 100644 --- a/src/lib/unlang/foreach.c +++ b/src/lib/unlang/foreach.c @@ -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; } diff --git a/src/lib/unlang/module.c b/src/lib/unlang/module.c index 78593070ab1..b0356d42ab3 100644 --- a/src/lib/unlang/module.c +++ b/src/lib/unlang/module.c @@ -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; } diff --git a/src/lib/unlang/module.h b/src/lib/unlang/module.h index 5cc105e3305..bf4ddb3aa7f 100644 --- a/src/lib/unlang/module.h +++ b/src/lib/unlang/module.h @@ -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); diff --git a/src/lib/unlang/transaction_priv.h b/src/lib/unlang/transaction_priv.h index 315ca349969..9babcdb29bf 100644 --- a/src/lib/unlang/transaction_priv.h +++ b/src/lib/unlang/transaction_priv.h @@ -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 diff --git a/src/lib/unlang/xlat.c b/src/lib/unlang/xlat.c index 68819f9f5c7..a90773df51b 100644 --- a/src/lib/unlang/xlat.c +++ b/src/lib/unlang/xlat.c @@ -28,6 +28,7 @@ RCSID("$Id$") #include #include +#include #include #include #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; } diff --git a/src/lib/unlang/xlat.h b/src/lib/unlang/xlat.h index d4dc26606ad..6eaa613fc96 100644 --- a/src/lib/unlang/xlat.h +++ b/src/lib/unlang/xlat.h @@ -63,6 +63,7 @@ typedef ssize_t (*xlat_escape_legacy_t)(request_t *request, char *out, size_t ou #include #include +#include /** 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); diff --git a/src/lib/unlang/xlat_builtin.c b/src/lib/unlang/xlat_builtin.c index 8ee093a5166..fcd66014761 100644 --- a/src/lib/unlang/xlat_builtin.c +++ b/src/lib/unlang/xlat_builtin.c @@ -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; diff --git a/src/lib/unlang/xlat_eval.c b/src/lib/unlang/xlat_eval.c index 842938dbc8d..720e6cab355 100644 --- a/src/lib/unlang/xlat_eval.c +++ b/src/lib/unlang/xlat_eval.c @@ -28,6 +28,8 @@ RCSID("$Id$") #include #include +#include +#include #include 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: diff --git a/src/lib/unlang/xlat_expr.c b/src/lib/unlang/xlat_expr.c index 43cae3aea08..d9d326329cb 100644 --- a/src/lib/unlang/xlat_expr.c +++ b/src/lib/unlang/xlat_expr.c @@ -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; diff --git a/src/lib/unlang/xlat_priv.h b/src/lib/unlang/xlat_priv.h index ff1c3a1973b..9fca229d10d 100644 --- a/src/lib/unlang/xlat_priv.h +++ b/src/lib/unlang/xlat_priv.h @@ -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, diff --git a/src/lib/unlang/xlat_purify.c b/src/lib/unlang/xlat_purify.c index 472aa05d4f1..58db33a9fb8 100644 --- a/src/lib/unlang/xlat_purify.c +++ b/src/lib/unlang/xlat_purify.c @@ -27,6 +27,7 @@ RCSID("$Id$") #include +#include #include #include @@ -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 diff --git a/src/lib/unlang/xlat_redundant.c b/src/lib/unlang/xlat_redundant.c index 391fd89ac01..c171c5e99c8 100644 --- a/src/lib/unlang/xlat_redundant.c +++ b/src/lib/unlang/xlat_redundant.c @@ -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; diff --git a/src/modules/rlm_sqlcounter/rlm_sqlcounter.c b/src/modules/rlm_sqlcounter/rlm_sqlcounter.c index 98b9f9d8651..acd381390e6 100644 --- a/src/modules/rlm_sqlcounter/rlm_sqlcounter.c +++ b/src/modules/rlm_sqlcounter/rlm_sqlcounter.c @@ -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; }