From: Alan T. DeKok Date: Sat, 18 Jan 2025 23:05:54 +0000 (-0500) Subject: set rhs_rules->enumv to LHS attribute for map parsing X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba0426f1e802b8d462367a1dbf62ce074d35f52f;p=thirdparty%2Ffreeradius-server.git set rhs_rules->enumv to LHS attribute for map parsing --- diff --git a/src/lib/server/map.c b/src/lib/server/map.c index 5a784885f04..4f3cb949508 100644 --- a/src/lib/server/map.c +++ b/src/lib/server/map.c @@ -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