]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
remove flags.virtual from the dictionaries
authorAlan T. DeKok <aland@freeradius.org>
Mon, 4 Sep 2023 01:10:02 +0000 (21:10 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 4 Sep 2023 01:10:45 +0000 (21:10 -0400)
all attributes are now realized.

src/lib/unlang/compile.c
src/lib/unlang/xlat_expr.c
src/lib/unlang/xlat_tokenize.c
src/lib/util/dict.h
src/lib/util/dict_print.c
src/lib/util/dict_tokenize.c
src/lib/util/dict_validate.c

index 7c4b1fa8322d121167f744d0e3be3b0067c09937..0c8a2dc6135d2796378fb371fdbb62af2f737311 100644 (file)
@@ -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
         */
index a6e2025ac2034d876ba4eae27270eba16c27ddff..47fa92881f0cb3541dc79bf97aad447614aefe5a 100644 (file)
@@ -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);
index 6934d7da5e2a1d80650b54f248df1a6b033dcbcf..d1e8b3c750f65454fee63e9baeb3bcb531f4c772 100644 (file)
@@ -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;
                }
        }
 
index f7c0e248b51745c7907af1bbe8c58f9c15479fae..d4c5606597bb3000d7562c08dcfb5b021b97a903 100644 (file)
@@ -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
index 0a8aa4133c4787ed2840415d05083e29d713e370..127c079724f256f49a7bb580b903c657ecded59e 100644 (file)
@@ -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);
 
index 8f4d4af4a50df3c7f742c5ad7540ce27fc42cd62..1ab28c515bd6d22ed0779e1af2ad260187fb062e 100644 (file)
@@ -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;
 
index 764030c30aba7e3ec22b555f46633a1958fd638e..aa891a90f72a6f05e98e62f1e61aae4e6762f027 100644 (file)
@@ -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.