]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
try to parse things inside of a {...} block
authorAlan T. DeKok <aland@freeradius.org>
Thu, 19 Oct 2023 21:12:23 +0000 (17:12 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 19 Oct 2023 21:12:23 +0000 (17:12 -0400)
if this doesn't work, it should be reverted

src/lib/server/map.c

index 09d05be3aa9f92161f601a45aac088879218ffba..86f6d66ccebe9651de6991b9b99c36b2d1ea83d3 100644 (file)
@@ -412,7 +412,9 @@ ssize_t map_afrom_substr(TALLOC_CTX *ctx, map_t **out, map_t **parent_p, fr_sbuf
        fr_sbuff_t                      our_in = FR_SBUFF(in);
        fr_sbuff_marker_t               m_lhs, m_rhs, m_op;
        fr_sbuff_term_t const           *tt = p_rules ? p_rules->terminals : NULL;
-       map_t                           *parent, *new_parent;
+       map_t                           *parent, *new_parent, *child;
+       tmpl_rules_t                    our_lhs_rules;
+
 
        if (parent_p) {
                new_parent = parent = *parent_p;
@@ -440,8 +442,6 @@ ssize_t map_afrom_substr(TALLOC_CTX *ctx, map_t **out, map_t **parent_p, fr_sbuf
 
        default:
        {
-               tmpl_rules_t our_lhs_rules;
-
                if (lhs_rules) {
                        our_lhs_rules = *lhs_rules;
                } else {
@@ -594,6 +594,26 @@ ssize_t map_afrom_substr(TALLOC_CTX *ctx, map_t **out, map_t **parent_p, fr_sbuf
 
                        fr_sbuff_adv_past_whitespace(&our_in, SIZE_MAX, tt);
 
+                       if (lhs_rules) {
+                               our_lhs_rules = *lhs_rules;
+                       } else {
+                               memset(&our_lhs_rules, 0, sizeof(our_lhs_rules));
+                       }
+                       our_lhs_rules.attr.namespace = tmpl_attr_tail_da(map->lhs);
+
+                       if (map_afrom_attr_str(map, &child, fr_sbuff_current(&our_in), &our_lhs_rules, rhs_rules) < 0) {
+                               fr_sbuff_set(&our_in, &m_rhs);
+                               fr_strerror_const("Failed parsing map contents");
+                               goto error;
+                       }
+                       map_list_insert_tail(&map->child, child);
+
+                       /*
+                        *      @todo - check for commas and repeat?
+                        */
+
+                       fr_sbuff_adv_past_whitespace(&our_in, SIZE_MAX, tt);
+
                        /*
                         *      Peek at the next character.  If it's
                         *      '}', stop.  Otherwise, call ourselves