]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
limit where ALIASes can go.
authorAlan T. DeKok <aland@freeradius.org>
Wed, 26 Nov 2025 14:05:29 +0000 (09:05 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 26 Nov 2025 14:05:29 +0000 (09:05 -0500)
because it doesn't make sense to have them in 'group', for example

src/lib/util/dict_tokenize.c
src/lib/util/dict_util.c

index 25c1038af295d2070f9fa851766096dbed5a08b3..d2bc4b0cab786bf2d5cd20509373dd3978910ea6 100644 (file)
@@ -1395,6 +1395,24 @@ static int dict_read_process_alias(dict_tokenize_ctx_t *dctx, char **argv, int a
                return -1;
        }
 
+       /*
+        *      Internally we can add aliases to STRUCTs.  But the poor user can't.
+        *
+        *      This limitation is mainly so that we can differentiate automatically added aliases (which
+        *      point to unions), from ones added by users.  If we make dict_attr_acopy_aliases() a little
+        *      smarter, then we can relax those checks.
+        */
+       switch (parent->type) {
+       case FR_TYPE_TLV:
+       case FR_TYPE_VSA:
+       case FR_TYPE_VENDOR:
+               break;
+
+       default:
+               fr_strerror_printf("ALIAS cannot be added to data type '%s'", fr_type_to_str(parent->type));
+               return -1;
+       }
+
        /*
         *      Relative refs get resolved from the current namespace.
         */
index aedf5f7b488a4f4cb48fe5c785ff068303418d34..494eaac6a1ed2fa70ecdd28b02c7f5a30d7b7118 100644 (file)
@@ -1410,11 +1410,17 @@ int dict_attr_alias_add(fr_dict_attr_t const *parent, char const *alias, fr_dict
                break;
 
        default:
-               fr_strerror_printf("Cannot add ALIAS to %s of data type '%s'",
+               fr_strerror_printf("Cannot add ALIAS to parent attribute %s of data type '%s'",
                                   parent->name, fr_type_to_str(parent->type));
                return -1;
        }
 
+       if ((ref->type == FR_TYPE_UNION) || fr_dict_attr_is_key_field(ref)) {
+               fr_strerror_printf("Cannot add ALIAS to target attribute %s of data type '%s'",
+                                  ref->name, fr_type_to_str(ref->type));
+               return -1;
+       }
+
        da = dict_attr_by_name(NULL, parent, alias);
        if (da) {
                fr_strerror_printf("ALIAS '%s' conflicts with another attribute in namespace %s",