From: Alan T. DeKok Date: Thu, 9 Apr 2020 12:29:59 +0000 (-0400) Subject: rework so CHILD_GROUP is no longer necessary X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=caa3394752b2ef23d4b340217a6cbabdabef127b;p=thirdparty%2Ffreeradius-server.git rework so CHILD_GROUP is no longer necessary --- diff --git a/src/lib/unlang/xlat.c b/src/lib/unlang/xlat.c index 0bea6356aa1..ed7c8f863bf 100644 --- a/src/lib/unlang/xlat.c +++ b/src/lib/unlang/xlat.c @@ -265,27 +265,6 @@ static unlang_action_t unlang_xlat(REQUEST *request, rlm_rcode_t *presult) unlang_xlat_push(state->ctx, &state->rhead, request, child, false); return UNLANG_ACTION_PUSHED_CHILD; - case XLAT_ACTION_PUSH_CHILD_GROUP: - rad_assert(child); - - repeatable_set(frame); - - /* - * Clear out the results of any previous expansions - * at this level. A frame may be used to evaluate - * multiple sibling nodes. - */ - talloc_list_free(&state->rhead); - - /* - * The called function can't pass us a value box, - * so we have to create it ourselves. - */ - state->rhead = fr_value_box_alloc(state->ctx, FR_TYPE_GROUP, NULL, false); - - unlang_xlat_push(state->ctx, &state->rhead->vb_group, request, child, false); - return UNLANG_ACTION_PUSHED_CHILD; - case XLAT_ACTION_YIELD: if (!state->resume) { RWDEBUG("Missing call to unlang_xlat_yield()"); @@ -362,7 +341,6 @@ static unlang_action_t unlang_xlat_resume(REQUEST *request, rlm_rcode_t *presult return UNLANG_ACTION_CALCULATE_RESULT; case XLAT_ACTION_PUSH_CHILD: - case XLAT_ACTION_PUSH_CHILD_GROUP: rad_assert(0); /* FALL-THROUGH */ diff --git a/src/lib/unlang/xlat.h b/src/lib/unlang/xlat.h index a368ba305a4..9a4942309ef 100644 --- a/src/lib/unlang/xlat.h +++ b/src/lib/unlang/xlat.h @@ -34,7 +34,6 @@ extern "C" { */ typedef enum { XLAT_ACTION_PUSH_CHILD = 1, //!< A deeper level of nesting needs to be evaluated. - XLAT_ACTION_PUSH_CHILD_GROUP, //!< same as above, and the child is a group XLAT_ACTION_YIELD, //!< An xlat function pushed a resume frame onto the stack. XLAT_ACTION_DONE, //!< We're done evaluating this level of nesting. XLAT_ACTION_FAIL //!< An xlat function failed. diff --git a/src/lib/unlang/xlat_eval.c b/src/lib/unlang/xlat_eval.c index 224969e7478..036d2d5a4c4 100644 --- a/src/lib/unlang/xlat_eval.c +++ b/src/lib/unlang/xlat_eval.c @@ -87,7 +87,6 @@ fr_table_num_sorted_t const xlat_action_table[] = { { "done", XLAT_ACTION_DONE }, { "fail", XLAT_ACTION_FAIL }, { "push-child", XLAT_ACTION_PUSH_CHILD }, - { "push-child-group", XLAT_ACTION_PUSH_CHILD_GROUP }, { "yield", XLAT_ACTION_YIELD } }; size_t xlat_action_table_len = NUM_ELEMENTS(xlat_action_table); @@ -844,11 +843,6 @@ xlat_action_t xlat_frame_eval_repeat(TALLOC_CTX *ctx, fr_cursor_t *out, RDEBUG2(" -- CHILD"); return xa; - - case XLAT_ACTION_PUSH_CHILD_GROUP: - RDEBUG2(" -- CHILD-GROUP"); - return xa; - case XLAT_ACTION_YIELD: RDEBUG2(" -- YIELD"); return xa; @@ -909,19 +903,24 @@ xlat_action_t xlat_frame_eval_repeat(TALLOC_CTX *ctx, fr_cursor_t *out, case XLAT_CHILD: { fr_cursor_t from; + fr_value_box_t *box; XLAT_DEBUG("** [%i] %s(child) - continuing %%{%s ...}", unlang_interpret_stack_depth(request), __FUNCTION__, node->fmt); rad_assert(*result != NULL); + (void) talloc_list_get_type_abort(*result, fr_value_box_t); + + box = fr_value_box_alloc(ctx, FR_TYPE_GROUP, NULL, false); + box->vb_group = *result; + *result = NULL; xlat_debug_log_expansion(request, *in, NULL); - xlat_debug_log_result(request, *result); + xlat_debug_log_result(request, box); - (void) talloc_list_get_type_abort(*result, fr_value_box_t); - fr_cursor_init(&from, result); + fr_cursor_init(&from, &box); fr_cursor_merge(out, &from); - rad_assert(!*result); + rad_assert(!box); } break; @@ -1105,7 +1104,7 @@ xlat_action_t xlat_frame_eval(TALLOC_CTX *ctx, fr_cursor_t *out, xlat_exp_t cons * for evaluation. */ *child = node->child; - xa = XLAT_ACTION_PUSH_CHILD_GROUP; + xa = XLAT_ACTION_PUSH_CHILD; goto finish; } }