]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
use pair_append_by_tmpl_parent() instead of fr_pair_afrom_da()
authorAlan T. DeKok <aland@freeradius.org>
Tue, 4 Jul 2023 19:14:37 +0000 (15:14 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 4 Jul 2023 19:14:37 +0000 (15:14 -0400)
as the tmpl function finds or creates all of the pairs in the
map.

The mschap tests expected that to work:

&request += {
&Vendor-Specific.Microsoft.CHAP-Challenge = 0xe96e4fff2955c4f1
&Vendor-Specific.Microsoft.CHAP-Response = 0x000100000...
}

Would create:

&request {
CHAP-Challenge = ...
CHAP-Response = ...
}

which was wrong

src/lib/unlang/edit.c
src/tests/keywords/all.mk

index 2e226ec3db75ca17f78d4bbacbf8ab2150a058a0..0fca5423f63ad1aaea0285c88ad65cf6e216d6c7 100644 (file)
@@ -580,18 +580,23 @@ static int apply_edits_to_leaf(request_t *request, unlang_frame_state_edit_t *st
         *      the appropriate place.
         */
        if (current->temporary_pair_list) {
-               fr_dict_attr_t const *da = tmpl_attr_tail_da(current->lhs.vpt);
                fr_pair_list_t *list = &current->parent->rhs.pair_list;
+               fr_pair_t *vp;
 
                while (box) {
-                       fr_pair_t *vp;
+                       /*
+                        *      Create (or find) all intermediate attributes.  The LHS map might have multiple
+                        *      attribute names in it.
+                        *
+                        *      @todo - audit other uses of tmpl_attr_tail_da() and fr_pair_afrom_da() in this file.
+                        */
+                       if (pair_append_by_tmpl_parent(current->parent->lhs.vp, &vp, list, current->lhs.vpt, true) < 0) {
+                               RWDEBUG("Failed creating attribute %s", current->lhs.vpt->name);
+                               return -1;
+                       }
 
-                       MEM(vp = fr_pair_afrom_da(current->parent->lhs.vp, da));
                        vp->op = map->op;
                        if (fr_value_box_cast(vp, &vp->data, vp->da->type, vp->da, box) < 0) return -1;
-                       if (fr_pair_append(list, vp) < 0) return -1;
-
-//                     RDEBUG2("%s %s %pV", current->lhs.vpt->name, fr_tokens[map->op], &vp->data);
 
                        if (single) break;
 
index 7ba440e24db79af8ddef99754bfaa383c23612af..8160ec66aeb1ac11dd53480a1ce204d5a178a81e 100644 (file)
@@ -71,7 +71,7 @@ KEYWORD_UPDATE_TESTS := update-attr-ref-null update-error-3 update-group-error u
 KEYWORD_UPDATE_REWRITE_TESTS := update-all update-array update-delete update-remove-any update-group update-hex update-remove-value update-index update-list-error update-remove-list update-prepend unknown-update  update-error update-error-2 update-exec-error update-list-null-rhs update-exec
 
 # Tests which can use new conditions, but which can't use tmpl_tokenize_all_nested=yes
-KEYWORD_UPDATE_TMPL_TESTS      := foreach-regex mschap pairs xlat-dhcpv4
+KEYWORD_UPDATE_TMPL_TESTS      := foreach-regex pairs xlat-dhcpv4
 
 #
 #  Migration support.  Some of the tests don't run under the new