From: Alan T. DeKok Date: Fri, 10 Dec 2021 23:40:04 +0000 (-0500) Subject: remove xlat_eval_pair() now that nothing sets VT_XLAT X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ac3a8979268b2f7bcbbe99b214f74429939eb76;p=thirdparty%2Ffreeradius-server.git remove xlat_eval_pair() now that nothing sets VT_XLAT and update radius_pairmove() to no longer take "do_xlat" flag --- diff --git a/src/lib/server/paircmp.c b/src/lib/server/paircmp.c index c5a0d33403..dbcf67536a 100644 --- a/src/lib/server/paircmp.c +++ b/src/lib/server/paircmp.c @@ -582,12 +582,6 @@ int paircmp(request_t *request, */ if (check_item->op == T_OP_CMP_FALSE) return -1; - /* - * We've got to xlat the string before doing - * the comparison. - */ - xlat_eval_pair(request, check_item); - /* * OK it is present now compare them. */ diff --git a/src/lib/server/pairmove.c b/src/lib/server/pairmove.c index 69d9c55e21..9f217e4896 100644 --- a/src/lib/server/pairmove.c +++ b/src/lib/server/pairmove.c @@ -42,7 +42,7 @@ RCSID("$Id$") * only fr_pair_list_copy() those attributes that we're really going to * use. */ -void radius_pairmove(request_t *request, fr_pair_list_t *to, fr_pair_list_t *from, bool do_xlat) +void radius_pairmove(request_t *request, fr_pair_list_t *to, fr_pair_list_t *from) { int i, j, count, to_count, tailto; fr_pair_t *from_vp, *next_from, *to_vp, *next_to = NULL; @@ -96,8 +96,6 @@ void radius_pairmove(request_t *request, fr_pair_list_t *to, fr_pair_list_t *fro RDEBUG4("::: Examining %s", from_vp->da->name); - if (do_xlat) xlat_eval_pair(request, from_vp); - /* * Attribute should be appended, OR the "to" list * is empty, and we're supposed to replace or diff --git a/src/lib/server/pairmove.h b/src/lib/server/pairmove.h index 97b2035a32..40993bc171 100644 --- a/src/lib/server/pairmove.h +++ b/src/lib/server/pairmove.h @@ -32,7 +32,7 @@ RCSIDH(pairmove_h, "$Id$") extern "C" { #endif -void radius_pairmove(request_t *request, fr_pair_list_t *to, fr_pair_list_t *from, bool do_xlat) CC_HINT(nonnull); +void radius_pairmove(request_t *request, fr_pair_list_t *to, fr_pair_list_t *from) CC_HINT(nonnull); #ifdef __cplusplus } diff --git a/src/lib/unlang/xlat.h b/src/lib/unlang/xlat.h index f5d8e55955..c11b7c24ba 100644 --- a/src/lib/unlang/xlat.h +++ b/src/lib/unlang/xlat.h @@ -289,8 +289,6 @@ int xlat_aeval_compiled_argv(TALLOC_CTX *ctx, char ***argv, request_t *request, int xlat_flatten_compiled_argv(TALLOC_CTX *ctx, xlat_exp_t const ***argv, xlat_exp_t const *xlat); -int xlat_eval_pair(request_t *request, fr_pair_t *vp); - bool xlat_async_required(xlat_exp_t const *xlat); ssize_t xlat_tokenize_ephemeral(TALLOC_CTX *ctx, xlat_exp_t **head, diff --git a/src/lib/unlang/xlat_eval.c b/src/lib/unlang/xlat_eval.c index 19015f572e..70acc38f13 100644 --- a/src/lib/unlang/xlat_eval.c +++ b/src/lib/unlang/xlat_eval.c @@ -1647,55 +1647,6 @@ int xlat_flatten_compiled_argv(TALLOC_CTX *ctx, xlat_exp_t const ***argv, xlat_e return count; } -/** Expands an attribute marked with fr_pair_mark_xlat - * - * Writes the new value to the vp. - * - * @param request Current request. - * @param vp to expand. - * @return On failure pair will still no longer be marked for xlat expansion. - * - 0 if successful. - * - -1 On xlat failure. - * - -2 On parse failure. - */ -int xlat_eval_pair(request_t *request, fr_pair_t *vp) -{ - ssize_t slen; - - char *expanded = NULL; - if (vp->type != VT_XLAT) return 0; - - vp->type = VT_DATA; - - slen = xlat_aeval(request, &expanded, request, vp->xlat, NULL, NULL); - talloc_const_free(vp->xlat); - vp->xlat = NULL; - if (slen < 0) { - return -1; - } - - /* - * Parse the string into a new value. - * - * If the fr_pair_t is being used in a regular expression - * then we just want to copy the new value in unmolested. - */ - if ((vp->op == T_OP_REG_EQ) || (vp->op == T_OP_REG_NE)) { - fr_pair_value_bstrdup_buffer(vp, expanded, vp->vp_tainted); - talloc_free(expanded); - return 0; - } - - if (fr_pair_value_from_str(vp, expanded, strlen(expanded), &fr_value_unescape_double, true) < 0){ - talloc_free(expanded); - return -2; - } - - talloc_free(expanded); - - return 0; -} - /** Walk over all xlat nodes (depth first) in a xlat expansion, calling a callback * * @param[in] exp to evaluate. diff --git a/src/modules/rlm_files/rlm_files.c b/src/modules/rlm_files/rlm_files.c index 0ec935b84b..16479bfb4c 100644 --- a/src/modules/rlm_files/rlm_files.c +++ b/src/modules/rlm_files/rlm_files.c @@ -565,7 +565,7 @@ redo: } } - radius_pairmove(request, &request->reply_pairs, &tmp_list, true); + radius_pairmove(request, &request->reply_pairs, &tmp_list); } } diff --git a/src/modules/rlm_mruby/rlm_mruby.c b/src/modules/rlm_mruby/rlm_mruby.c index c85801cfcd..c2f973605b 100644 --- a/src/modules/rlm_mruby/rlm_mruby.c +++ b/src/modules/rlm_mruby/rlm_mruby.c @@ -385,7 +385,7 @@ static void add_vp_tuple(TALLOC_CTX *ctx, request_t *request, fr_pair_list_t *vp fr_pair_append(&tmp_list, vp); } - radius_pairmove(request, vps, &tmp_list, false); + radius_pairmove(request, vps, &tmp_list); } static inline int mruby_set_vps(request_t *request, mrb_state *mrb, mrb_value mruby_request, diff --git a/src/modules/rlm_python/rlm_python.c b/src/modules/rlm_python/rlm_python.c index 4a6d760905..12931d4a0b 100644 --- a/src/modules/rlm_python/rlm_python.c +++ b/src/modules/rlm_python/rlm_python.c @@ -353,7 +353,7 @@ static void mod_vptuple(TALLOC_CTX *ctx, module_ctx_t const *mctx, request_t *re fr_pair_append(&tmp_list, vp); } - radius_pairmove(request, vps, &tmp_list, false); + radius_pairmove(request, vps, &tmp_list); } diff --git a/src/modules/rlm_rest/rest.c b/src/modules/rlm_rest/rest.c index eabd0f097f..5194ce89bf 100644 --- a/src/modules/rlm_rest/rest.c +++ b/src/modules/rlm_rest/rest.c @@ -1157,7 +1157,7 @@ static int json_pair_alloc(rlm_rest_t const *instance, rlm_rest_section_t const fr_pair_list_t tmp_list; fr_pair_list_init(&tmp_list); fr_pair_append(&tmp_list, vp); - radius_pairmove(current, vps, &tmp_list, false); + radius_pairmove(current, vps, &tmp_list); /* * If we call json_object_array_get_idx on something that's not an array * the behaviour appears to be to occasionally segfault. diff --git a/src/modules/rlm_sql/rlm_sql.c b/src/modules/rlm_sql/rlm_sql.c index c672e411a7..6b215d906c 100644 --- a/src/modules/rlm_sql/rlm_sql.c +++ b/src/modules/rlm_sql/rlm_sql.c @@ -934,7 +934,7 @@ static unlang_action_t rlm_sql_process_groups(rlm_rcode_t *p_result, RDEBUG2("&%pP", vp); } REXDENT(); - radius_pairmove(request, &request->control_pairs, &check_tmp, true); + radius_pairmove(request, &request->control_pairs, &check_tmp); fr_pair_list_free(&check_tmp); } @@ -972,7 +972,7 @@ static unlang_action_t rlm_sql_process_groups(rlm_rcode_t *p_result, log_request_pair_list(L_DBG_LVL_2, request, NULL, &reply_tmp, NULL); - radius_pairmove(request, &request->reply_pairs, &reply_tmp, true); + radius_pairmove(request, &request->reply_pairs, &reply_tmp); fr_pair_list_free(&reply_tmp); /* * If there's no reply query configured, then we assume @@ -1315,7 +1315,7 @@ static unlang_action_t CC_HINT(nonnull) mod_authorize(rlm_rcode_t *p_result, mod RDEBUG2("&%pP", vp); } REXDENT(); - radius_pairmove(request, &request->control_pairs, &check_tmp, true); + radius_pairmove(request, &request->control_pairs, &check_tmp); rcode = RLM_MODULE_OK; fr_pair_list_free(&check_tmp); @@ -1350,7 +1350,7 @@ static unlang_action_t CC_HINT(nonnull) mod_authorize(rlm_rcode_t *p_result, mod log_request_pair_list(L_DBG_LVL_2, request, NULL, &reply_tmp, NULL); - radius_pairmove(request, &request->reply_pairs, &reply_tmp, true); + radius_pairmove(request, &request->reply_pairs, &reply_tmp); rcode = RLM_MODULE_OK; fr_pair_list_free(&reply_tmp);