From: Alan T. DeKok Date: Tue, 4 Jul 2023 14:28:13 +0000 (-0400) Subject: allow multiple attrs on the LHS X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01e9743379b052b66c590ab7a6e8a59b2dd6d7d9;p=thirdparty%2Ffreeradius-server.git allow multiple attrs on the LHS &reply.foo := { ... } --- diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index def10fd13fd..70585e73e85 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -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; } diff --git a/src/tests/keywords/all.mk b/src/tests/keywords/all.mk index ce73f0b9ac5..087b60eae6e 100644 --- a/src/tests/keywords/all.mk +++ b/src/tests/keywords/all.mk @@ -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 index 00000000000..2269b927d90 --- /dev/null +++ b/src/tests/keywords/edit-list-levels @@ -0,0 +1,12 @@ +# +# PRE: edit-list +# +&control.TLS-Certificate := { + &Issuer = "test" +} + +if !(&control.TLS-Certificate.Issuer == "test") { + test_fail +} + +success