From: Alan T. DeKok Date: Sun, 4 Dec 2022 14:33:04 +0000 (-0500) Subject: make redundant xlats work X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b26edf8d5123806644fe4f6f300f495c4422262b;p=thirdparty%2Ffreeradius-server.git make redundant xlats work via hackity hack, The real solution is not to copy the input (unexpanded) arguments. Instead, the xlat_redundant() call should simply copy it's expanded arguments, and call each function in turn. i.e. xlat_redundant() has no need to call xlat push or xlat yield, as it already has all of the arguments it needs. That also stops the inputs from being epanded repeatedly. --- diff --git a/src/lib/unlang/xlat_builtin.c b/src/lib/unlang/xlat_builtin.c index d9b0319add4..28ef3a6e0d1 100644 --- a/src/lib/unlang/xlat_builtin.c +++ b/src/lib/unlang/xlat_builtin.c @@ -801,7 +801,7 @@ static int xlat_redundant_instantiate(xlat_inst_ctx_t const *xctx) * a copy of the original arguments with each * function that's called. */ - fr_dlist_talloc_free(&xctx->ex->call.args->dlist); +// fr_dlist_talloc_free(&xctx->ex->call.args->dlist); return 0; } diff --git a/src/tests/keywords/xlat-redundant b/src/tests/keywords/xlat-redundant index 6e48ed7455d..e552cf9f318 100644 --- a/src/tests/keywords/xlat-redundant +++ b/src/tests/keywords/xlat-redundant @@ -2,7 +2,18 @@ # # PRE: if # -if ("%(concat:%(redundant_test:foo bar) '|')" != "foo|bar") { +if (!(%(concat:%(test1:foo bar) '|') == "foo|bar")) { + test_fail +} + +if (!(%(concat:%(test2:foo bar) '|') == "foo|bar")) { + test_fail +} + +# +# The config has a "redundant" block for test1 and test2. +# +if (!(%(concat:%(redundant_test:foo bar) '|') == "foo|bar")) { test_fail }