]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
allow multiple attrs on the LHS
authorAlan T. DeKok <aland@freeradius.org>
Tue, 4 Jul 2023 14:28:13 +0000 (10:28 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 4 Jul 2023 14:28:41 +0000 (10:28 -0400)
&reply.foo := { ... }

src/lib/unlang/compile.c
src/tests/keywords/all.mk
src/tests/keywords/edit-list-levels [new file with mode: 0644]

index def10fd13fd8e3cde4654c91a4122b2336a197b9..70585e73e8503d5bfeb8eee47178317e6214cc74 100644 (file)
@@ -1819,6 +1819,15 @@ static unlang_t *compile_edit_section(unlang_t *parent, unlang_compile_t *unlang
        if (fr_type_is_structural(parent_da->type)) {
                map_t *child;
 
+               /*
+                *      Don't update namespace for &reply += { ... }
+                *
+                *      Do update namespace for &reply.foo += { ... }
+                */
+               if ((tmpl_attr_num_elements(map->lhs) > 1) && (t_rules.attr.list_def != parent_da)) {
+                       t_rules.attr.namespace = parent_da;
+               }
+
                if (map_afrom_cs_edit(map, &map->child, cs, &t_rules, &t_rules, unlang_fixup_edit, map, 256) < 0) {
                        goto fail;
                }
index ce73f0b9ac5765c790e6572b06c8ca1b79115192..087b60eae6e7ac794f8a66c90453d1c50f4cdded 100644 (file)
@@ -67,6 +67,8 @@ KEYWORD_UPDATE_TESTS := update-attr-ref-null update-error-3 update-group-error u
 
 KEYWORD_UPDATE_REWRITE_TESTS := update-all update-array update-delete update-remove-any update-group update-hex update-remove-value update-index update-list-error update-remove-list update-prepend unknown-update  update-error update-error-2 update-exec-error update-list-null-rhs update-exec
 
+KEYWORD_UPDATE_TMPL_TESTS      := edit-list-levels
+
 #
 #  Migration support.  Some of the tests don't run under the new
 #  conditions, so we don't run them under the new conditions.
@@ -77,6 +79,8 @@ else ifneq "$(findstring ${1}, comments update-to-edit if-regex-multivalue smash
 $(OUTPUT)/${1}: NEW_COND=-S use_new_conditions=yes
 else ifneq "$(findstring ${1}, $(KEYWORD_UPDATE_REWRITE_TESTS))" ""
 $(OUTPUT)/${1}: NEW_COND=-S use_new_conditions=yes -S rewrite_update=yes
+else ifneq "$(findstring ${1}, $(KEYWORD_UPDATE_TMPL_TESTS))" ""
+$(OUTPUT)/${1}: NEW_COND=-S use_new_conditions=yes -S rewrite_update=yes -S tmpl_tokenize_all_nested=yes
 else
 $(OUTPUT)/${1}: NEW_COND=-S use_new_conditions=yes -S forbid_update=yes
 
diff --git a/src/tests/keywords/edit-list-levels b/src/tests/keywords/edit-list-levels
new file mode 100644 (file)
index 0000000..2269b92
--- /dev/null
@@ -0,0 +1,12 @@
+#
+#  PRE: edit-list
+#
+&control.TLS-Certificate := {
+       &Issuer = "test"
+}
+
+if !(&control.TLS-Certificate.Issuer == "test") {
+       test_fail
+}
+
+success