]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
set rhs_rules->enumv to LHS attribute for map parsing
authorAlan T. DeKok <aland@freeradius.org>
Sat, 18 Jan 2025 23:05:54 +0000 (18:05 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 19 Jan 2025 01:52:07 +0000 (20:52 -0500)
src/lib/server/map.c

index 5a784885f04a0b5fbae5e71b35f7a3aaa8d399a1..4f3cb949508771f3b71eafb27517d14130059eaa 100644 (file)
@@ -201,6 +201,18 @@ int map_afrom_cp(TALLOC_CTX *ctx, map_t **out, map_t *parent, CONF_PAIR *cp,
                        if ((map->op != T_OP_RSHIFT_EQ) && (map->op != T_OP_LSHIFT_EQ)) {
                                my_rhs_rules.enumv = tmpl_attr_tail_da(map->lhs);
                        }
+               } else {
+                       /*
+                        *      If we parsed an attribute on the LHS, and the RHS looks like an enumerated
+                        *      value, then set the enumv.
+                        *
+                        *      @todo tmpl_require_enum_prefix - maybe just _always_ set enumv, because the
+                        *      caller shouldn't have set it?
+                        */
+                       if (!rhs_rules->enumv && tmpl_is_attr(map->lhs) &&
+                           (value[0] == ':') && value[1] == ':') {
+                               my_rhs_rules.enumv = tmpl_attr_tail_da(map->lhs);
+                       }
                }
                break;
        }
@@ -655,8 +667,24 @@ parse_rhs:
                        (void) tmpl_afrom_value_box(map, &map->rhs, fr_box_strvalue("ANY"), false);
 
                } else {
+                       tmpl_rules_t my_rhs_rules;
+
                        if (!p_rules) p_rules = &value_parse_rules_bareword_quoted;
 
+                       /*
+                        *      If we parsed an attribute on the LHS, and the RHS looks like an enumerated
+                        *      value, then set the enumv.
+                        *
+                        *      @todo tmpl_require_enum_prefix - maybe just _always_ set enumv, because the
+                        *      caller shouldn't have set it?
+                        */
+                       if (rhs_rules && !rhs_rules->enumv && tmpl_is_attr(map->lhs) &&
+                           fr_sbuff_is_str_literal(&our_in, "::")) {
+                               my_rhs_rules = *rhs_rules;
+                               my_rhs_rules.enumv = tmpl_attr_tail_da(map->lhs);
+                               rhs_rules = &my_rhs_rules;
+                       }
+
                        /*
                         *      Use the RHS termination rules ONLY for bare
                         *      words.  For quoted strings we already know how