From: Alan T. DeKok Date: Mon, 4 Sep 2023 01:10:02 +0000 (-0400) Subject: remove flags.virtual from the dictionaries X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06b06daf50c4092fe00d8b2bcaca0d08d98ee8a8;p=thirdparty%2Ffreeradius-server.git remove flags.virtual from the dictionaries all attributes are now realized. --- diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index 7c4b1fa8322..0c8a2dc6135 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -242,20 +242,6 @@ static bool pass2_fixup_tmpl(TALLOC_CTX *ctx, tmpl_t **vpt_p, CONF_ITEM const *c */ if (!vpt->rules.attr.dict_def) tmpl_set_dict_def(vpt, dict); - /* - * Convert virtual &Attr-Foo to "%{Attr-Foo}" - */ - if (tmpl_is_attr(vpt) && tmpl_attr_tail_da(vpt)->flags.virtual) { - if (tmpl_attr_to_xlat(ctx, vpt_p) < 0) { - return false; - } - - /* - * The VPT has been rewritten, so use the new one. - */ - vpt = *vpt_p; - } /* it's now xlat, so we need to resolve it. */ - /* * Fixup any other tmpl types */ diff --git a/src/lib/unlang/xlat_expr.c b/src/lib/unlang/xlat_expr.c index a6e2025ac20..47fa92881f0 100644 --- a/src/lib/unlang/xlat_expr.c +++ b/src/lib/unlang/xlat_expr.c @@ -1484,11 +1484,7 @@ static xlat_action_t xlat_attr_exists(TALLOC_CTX *ctx, fr_dcursor_t *out, MEM(dst = fr_value_box_alloc(ctx, FR_TYPE_BOOL, attr_expr_bool_enum)); vp = tmpl_dcursor_init(NULL, NULL, &cc, &cursor, request, vpt); - if (!vp) { - dst->vb_bool = tmpl_is_attr(vpt) && tmpl_attr_tail_da(vpt)->flags.virtual; - } else { - dst->vb_bool = true; - } + dst->vb_bool = (vp != NULL); if (do_free) talloc_const_free(vpt); tmpl_dcursor_clear(&cc); diff --git a/src/lib/unlang/xlat_tokenize.c b/src/lib/unlang/xlat_tokenize.c index 6934d7da5e2..d1e8b3c750f 100644 --- a/src/lib/unlang/xlat_tokenize.c +++ b/src/lib/unlang/xlat_tokenize.c @@ -700,33 +700,10 @@ static inline int xlat_tokenize_attribute(xlat_exp_head_t *head, fr_sbuff_t *in, FR_SBUFF_ERROR_RETURN(in); } - /* - * Deal with virtual attributes. - */ - if (tmpl_is_attr(vpt) && tmpl_attr_tail_da(vpt)->flags.virtual) { - if (tmpl_attr_num_elements(vpt) > 2) { - fr_strerror_const("Virtual attributes cannot be nested."); - goto error; - } - - /* - * This allows xlat functions to be - * used to provide values for virtual - * attributes. If we fail to resolve - * a virtual attribute to a function - * it's likely going to be handled as - * a virtual attribute by - * xlat_eval_pair_virtual - * - * We really need a virtual attribute - * registry so we can check if the - * attribute is valid. - */ - if (xlat_resolve_virtual_attribute(node, vpt) < 0) goto do_attr; /* * Deal with unresolved attributes. */ - } else if (tmpl_is_attr_unresolved(vpt)) { + if (tmpl_is_attr_unresolved(vpt)) { /* * Could it be a virtual attribute? */ @@ -2053,11 +2030,10 @@ int xlat_from_tmpl_attr(TALLOC_CTX *ctx, xlat_exp_head_t **out, tmpl_t **vpt_p) * see if it's actually a virtual attribute. */ if ((tmpl_attr_num_elements(vpt) == 1) || - (((tmpl_attr_list_head(tmpl_attr(vpt))->da) == request_attr_request) && tmpl_attr_num_elements(vpt) == 2)){ - if (tmpl_is_attr(vpt) && tmpl_attr_tail_da(vpt)->flags.virtual) { - func = xlat_func_find(tmpl_attr_tail_da(vpt)->name, -1); + (((tmpl_attr_list_head(tmpl_attr(vpt))->da) == request_attr_request) && tmpl_attr_num_elements(vpt) == 2)) { + if (tmpl_is_attr_unresolved(vpt)) { + func = xlat_func_find(tmpl_attr_tail_unresolved(vpt), -1); if (!func) { - unresolved: node = xlat_exp_alloc(head, XLAT_VIRTUAL_UNRESOLVED, vpt->name, vpt->len); /* @@ -2070,17 +2046,11 @@ int xlat_from_tmpl_attr(TALLOC_CTX *ctx, xlat_exp_head_t **out, tmpl_t **vpt_p) goto done; } - virtual: node = xlat_exp_alloc(head, XLAT_VIRTUAL, vpt->name, vpt->len); node->vpt = talloc_move(node, vpt_p); node->call.func = func; node->flags = func->flags; goto done; - - } else if (tmpl_is_attr_unresolved(vpt)) { - func = xlat_func_find(tmpl_attr_tail_unresolved(vpt), -1); - if (!func) goto unresolved; - goto virtual; } } diff --git a/src/lib/util/dict.h b/src/lib/util/dict.h index f7c0e248b51..d4c5606597b 100644 --- a/src/lib/util/dict.h +++ b/src/lib/util/dict.h @@ -89,8 +89,6 @@ typedef struct { unsigned int has_value : 1; //!< Has a value. - unsigned int virtual : 1; //!< for dynamic expansion - unsigned int is_unsigned : 1; //!< hackity hack for dates and time deltas unsigned int counter : 1; //!< integer attribute is actually an impulse / counter diff --git a/src/lib/util/dict_print.c b/src/lib/util/dict_print.c index 0a8aa4133c4..127c079724f 100644 --- a/src/lib/util/dict_print.c +++ b/src/lib/util/dict_print.c @@ -39,7 +39,6 @@ ssize_t fr_dict_attr_flags_print(fr_sbuff_t *out, fr_dict_t const *dict, fr_type FLAG_SET(internal); FLAG_SET(array); FLAG_SET(has_value); - FLAG_SET(virtual); FLAG_SET(counter); FLAG_SET(name_only); diff --git a/src/lib/util/dict_tokenize.c b/src/lib/util/dict_tokenize.c index 8f4d4af4a50..1ab28c515bd 100644 --- a/src/lib/util/dict_tokenize.c +++ b/src/lib/util/dict_tokenize.c @@ -381,9 +381,6 @@ static int dict_process_flag_field(dict_tokenize_ctx_t *ctx, char *name, fr_type } else if (strcmp(key, "counter") == 0) { flags->counter = 1; - } else if (strcmp(key, "virtual") == 0) { - flags->virtual = 1; - } else if (strcmp(key, "secret") == 0) { flags->secret = 1; diff --git a/src/lib/util/dict_validate.c b/src/lib/util/dict_validate.c index 764030c30ab..aa891a90f72 100644 --- a/src/lib/util/dict_validate.c +++ b/src/lib/util/dict_validate.c @@ -44,7 +44,7 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, uint32_t all_flags; uint32_t shift_is_root, shift_internal; uint32_t shift_array, shift_has_value; - uint32_t shift_virtual, shift_subtype, shift_extra; + uint32_t shift_subtype, shift_extra; uint32_t shift_counter; fr_dict_attr_t const *v; @@ -60,7 +60,6 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, SET_FLAG(internal); SET_FLAG(array); SET_FLAG(has_value); - SET_FLAG(virtual); SET_FLAG(extra); SET_FLAG(counter); SET_FLAG(subtype); @@ -74,7 +73,6 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, // internal // array // has_value - // virtual // extra // encrypt // length @@ -158,24 +156,6 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, FORBID_OTHER_FLAGS(has_value); } - /* - * virtual attributes are special. - */ - if (flags->virtual) { - if (!parent->flags.is_root) { - fr_strerror_const("The 'virtual' flag can only be used for normal attributes"); - return false; - } - - if (attr && !flags->internal && (*attr <= (1 << (8 * parent->flags.type_size)))) { - fr_strerror_const("The 'virtual' flag can only be used for non-protocol attributes"); - return false; - } - - ALLOW_FLAG(internal); - FORBID_OTHER_FLAGS(virtual); - } - /* * The "extra" flag is a grab-bag of stuff, depending on * the data type.