From: Alan T. DeKok Date: Sat, 18 Mar 2023 18:27:34 +0000 (-0400) Subject: simplify setting of parent / namespace for grouping attributes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa8f79fba0d6324b9d183cc7d55204e2183cb70e;p=thirdparty%2Ffreeradius-server.git simplify setting of parent / namespace for grouping attributes we can't put random protocol attributes into an internal group, as there's no way to reference them --- diff --git a/src/lib/server/tmpl_tokenize.c b/src/lib/server/tmpl_tokenize.c index 3cab829b7f5..47b9f7176b0 100644 --- a/src/lib/server/tmpl_tokenize.c +++ b/src/lib/server/tmpl_tokenize.c @@ -1848,7 +1848,9 @@ do_suffix: switch (da->type) { /* * If this is a group then the parent is the - * group ref. + * group ref. If no explicit ref is set in the + * dictionary, the ref is the dict root of the + * attribute. * * The dictionary resolution functions will * automatically follow the ref, so we don't @@ -1861,23 +1863,23 @@ do_suffix: ref = fr_dict_attr_ref(da); /* - * if there's a real dictionary, and this reference is to group which is in fact - * the internal dict, then just keep using our dict_def. + * If we're swapping dictionaries, do so. Otherwise ref is to the internal + * dictionary, and we don't want to use that. + * + * Instead of using the internal dictionary, just reset parent / namespace to the + * root of dict_def. + * + * Note that means we cannot put random protocol attributes into an internal + * attribute of type "group". */ - if (at_rules->dict_def && (ref == fr_dict_root(fr_dict_internal()))) { - if (!namespace) namespace = ref; + if (ref != fr_dict_root(fr_dict_internal())) { + our_parent = namespace = ref; } else { - namespace = ref; - } - - /* - * If the group is from the internal dictionary, then reset the search - * for the child attribute. Protocol attributes are allowed inside - * internal group attributes. - */ - our_parent = (namespace && (namespace->dict == fr_dict_internal())) ? NULL : namespace; + fr_assert(at_rules->dict_def); + our_parent = namespace = fr_dict_root(at_rules->dict_def); + } break; case FR_TYPE_STRUCT: