From: Alan T. DeKok Date: Wed, 13 Aug 2025 14:56:12 +0000 (-0400) Subject: notes on MEMBER of type 'struct' with 'clone=ref' X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=232a28d696ce1b49094fc7c2aba3ebfec26cb786;p=thirdparty%2Ffreeradius-server.git notes on MEMBER of type 'struct' with 'clone=ref' it works in some cases, but not others. Document why, so we can remove other todo's from the list of v4 features --- diff --git a/src/lib/util/dict_tokenize.c b/src/lib/util/dict_tokenize.c index 3ba3e5cd2ae..607a3cc3cb8 100644 --- a/src/lib/util/dict_tokenize.c +++ b/src/lib/util/dict_tokenize.c @@ -480,6 +480,11 @@ static int dict_flag_clone(fr_dict_attr_t **da_p, char const *value, UNUSED fr_d */ if (unlikely(dict_attr_ref_aunresolved(da_p, value, FR_DICT_ATTR_REF_CLONE) < 0)) return -1; + /* + * We don't know how big the cloned reference is, so it isn't known width. + */ + (*da_p)->flags.is_known_width = 0; + return 0; } @@ -2291,6 +2296,13 @@ static int dict_read_process_member(dict_tokenize_ctx_t *dctx, char **argv, int * The solution is to update the unwind() function to check if the da we've * unwound to is a struct, and then if so... get the last child, and mark it * closed. + * + * @todo - a MEMBER which is of type 'struct' and has 'clone=foo', we delay the clone + * until after all of the dictionaries have been loaded. As such, this attribute + * is unknown width, and MUST be at the end of the parent structure. + * + * If the cloned MEMBER is in the middle of a structure, then the user will get an opaque + * error. But that case should be rare. */ if (!da->flags.is_known_width) dctx->stack[dctx->stack_depth].struct_is_closed = da; break;