]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
If we have a LHS leaf, pass it to the RHS tmpl parser
authorAlan T. DeKok <aland@freeradius.org>
Mon, 4 Sep 2023 19:54:14 +0000 (15:54 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 5 Sep 2023 13:29:51 +0000 (09:29 -0400)
which means that we catch more load-time errors for typos in
the configuration files.

and add test case.

The RHS resolution is done in pass2, so there's no issue with an
enum name being defined after the configuration files have been read.

src/lib/server/map.c
src/tests/keywords/edit-rhs-error [new file with mode: 0644]

index e3cc8cedf58625b8c0c4851732bec89ae38643c7..81e311c1dc32732d88727f465e54c64adbf71926 100644 (file)
@@ -190,8 +190,13 @@ int map_afrom_cp(TALLOC_CTX *ctx, map_t **out, map_t *parent, CONF_PAIR *cp,
                 */
                if (!input_rhs_rules) {
                        tmpl_rules_child_init(child_ctx, &my_rhs_rules, lhs_rules, map->lhs);
-                       rhs_rules = &my_rhs_rules;
+               } else {
+                       my_rhs_rules = *input_rhs_rules;
                }
+               rhs_rules = &my_rhs_rules;
+
+               da = tmpl_attr_tail_da(map->lhs);
+               if (edit && fr_type_is_leaf(da->type)) my_rhs_rules.enumv = tmpl_attr_tail_da(map->lhs);
                break;
        }
 
diff --git a/src/tests/keywords/edit-rhs-error b/src/tests/keywords/edit-rhs-error
new file mode 100644 (file)
index 0000000..1a011ad
--- /dev/null
@@ -0,0 +1,4 @@
+#
+#  The RHS isn't a number or an enum
+#
+&Tmp-Integer-0 := '$[3][2]'    # ERROR
\ No newline at end of file