]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Hack in pair_append_by_tmpl_parent to make key fields work
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 16 Mar 2024 00:14:47 +0000 (20:14 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 16 Mar 2024 00:15:39 +0000 (20:15 -0400)
src/lib/server/tmpl_eval.c

index 34df081ac615d68f25d495b429bb1e595d87789d..c34ce3a43289c510402048a04e4453367cf5b014 100644 (file)
@@ -996,8 +996,23 @@ int pair_append_by_tmpl_parent(TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t
                /*
                 *      We're not at the leaf, look for a potential parent
                 */
-               if (ar != leaf) vp = fr_pair_find_by_da(list, NULL, ar->da);
-
+               if (ar != leaf) {
+                       vp = fr_pair_find_by_da(list, NULL, ar->da);
+                       /*
+                        *      HACK - Pretend we didn't see this stupid key field
+                        *
+                        *      If we don't have this, the code creates a key pair
+                        *      and then horribly mangles its data by adding children
+                        *      to it.
+                        *
+                        *      We just skip one level down an don't create or update
+                        *      the key pair.
+                        */
+                       if (vp && fr_dict_attr_is_key_field(ar->da) && fr_type_is_leaf(vp->data.type)) {
+                               ar = tmpl_attr_list_next(ar_list, ar);
+                               continue;
+                       }
+               }
                /*
                 *      Nothing found, create the pair
                 */