From: Arran Cudbard-Bell Date: Sat, 16 Mar 2024 00:14:47 +0000 (-0400) Subject: Hack in pair_append_by_tmpl_parent to make key fields work X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bab67fab00fbb346de4b8360c22c6b9f7cc8284b;p=thirdparty%2Ffreeradius-server.git Hack in pair_append_by_tmpl_parent to make key fields work --- diff --git a/src/lib/server/tmpl_eval.c b/src/lib/server/tmpl_eval.c index 34df081ac61..c34ce3a4328 100644 --- a/src/lib/server/tmpl_eval.c +++ b/src/lib/server/tmpl_eval.c @@ -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 */