]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
update for tested VPs
authorAlan T. DeKok <aland@freeradius.org>
Wed, 12 Jul 2023 18:05:34 +0000 (14:05 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 12 Jul 2023 18:05:34 +0000 (14:05 -0400)
if we set the nested flag "true" and edit the tests, they should
all now pass.

src/lib/util/pair_legacy.c
src/tests/unit/file.txt

index 9057c468145eee5ef349664e1bee83b692cd94ac..04b025ee91a85acf77e51e3d427a4583f90d74d6 100644 (file)
@@ -81,7 +81,7 @@ static ssize_t fr_pair_list_afrom_substr(TALLOC_CTX *ctx, fr_dict_attr_t const *
 {
        fr_pair_t               *vp = NULL;
        fr_pair_t               *my_relative_vp;
-       char const              *p, *next;
+       char const              *p, *next, *op_p;
        fr_token_t              quote, last_token = T_INVALID;
        fr_dict_attr_t const    *internal = NULL;
        fr_pair_list_t          *my_list = list;
@@ -200,6 +200,7 @@ static ssize_t fr_pair_list_afrom_substr(TALLOC_CTX *ctx, fr_dict_attr_t const *
 
                p = next;
                fr_skip_whitespace(p);
+               op_p = p;
 
                /*
                 *      There must be an operator here.
@@ -213,11 +214,22 @@ static ssize_t fr_pair_list_afrom_substr(TALLOC_CTX *ctx, fr_dict_attr_t const *
 
                fr_skip_whitespace(p);
 
-               if (!nested || parent_vp)  {
+               if (!nested || parent_vp || (*relative_vp && ((*relative_vp)->da == da->parent)))  {
                        vp = fr_pair_afrom_da(my_ctx, da);
                        if (!vp) goto error;
                        fr_pair_append(my_list, vp);
 
+               } else if (*relative_vp) {
+
+                       if (op != T_OP_ADD_EQ) {
+                               fr_strerror_const("Relative attributes can only use '+=' for the operator");
+                               p = op_p;
+                               goto error;
+                       }
+
+                       vp = fr_pair_afrom_da_depth_nested(my_ctx, my_list, da, (*relative_vp)->da->depth);
+                       if (!vp) goto error;
+
                } else if (op != T_OP_ADD_EQ) {
                        fr_assert(op != T_OP_PREPEND);
 
index 4031e76e510ee194aaa8e43aed9b5ac0718ed286..35a81da1aa5f2f3530a8e7fc4d99de33efcd625b 100644 (file)
@@ -14,17 +14,36 @@ proto-dictionary radius
 read_file files/cisco_avpair.txt
 match User-Name = "bob", User-Password = "hello", Vendor-Specific.Cisco.AVPair = "1", Vendor-Specific.Cisco.AVPair += "2", Vendor-Specific.Cisco.AVPair += "3", Vendor-Specific.Cisco.AVPair += "4"
 
+# nested
+#match User-Name = "bob", User-Password = "hello", Vendor-Specific = { Cisco = { AVPair = "1", AVPair += "2", AVPair += "3", AVPair += "4" } }
+
 #
 #  Relative attributes, all on the same line.
 #
 read_file files/cisco_relative.txt
 match User-Name = "bob", User-Password = "hello", Vendor-Specific.Cisco = { AVPair = "1", AVPair += "2", AVPair += "3", AVPair += "4" }
 
+# nested
+#match User-Name = "bob", User-Password = "hello", Vendor-Specific = { Cisco = { AVPair = "1", AVPair += "2", AVPair += "3", AVPair += "4" } }
+
 #
 #  Relative attributes, each on a different line
 #
 read_file files/cisco_multiline_relative.txt
 match User-Name = "bob", User-Password = "hello", Vendor-Specific.Cisco = { AVPair = "1", AVPair += "2", AVPair += "3", AVPair += "4" }
 
+# nested
+#match User-Name = "bob", User-Password = "hello", Vendor-Specific = { Cisco = { AVPair = "1", AVPair += "2", AVPair += "3", AVPair += "4" } }
+
+
+#
+#  Multiple Cisco AVPAir, all on one line
+#
+read_file files/cisco_single_line.txt
+match User-Name = "bob", User-Password = "hello", Vendor-Specific.Cisco.AVPair = "1", Vendor-Specific.Cisco.AVPair += "2", Vendor-Specific.Cisco.AVPair += "3", Vendor-Specific.Cisco.AVPair += "4"
+
+# nested
+#match User-Name = "bob", User-Password = "hello", Vendor-Specific = { Cisco = { AVPair = "1", AVPair += "2", AVPair += "3", AVPair += "4" } }
+
 count
-match 7
+match 9