From: Alan T. DeKok Date: Tue, 22 Nov 2022 12:15:23 +0000 (-0500) Subject: don't auto-convert RHS xlats to attribute references X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f81b8293b08830a73ae75c3639636f594da9ae7a;p=thirdparty%2Ffreeradius-server.git don't auto-convert RHS xlats to attribute references if the caller cares, he can use &foo := %{eval:%{xlat}} If we care, we can add &foo := &%{xlat} --- diff --git a/src/lib/unlang/edit.c b/src/lib/unlang/edit.c index 601e7c820e2..ebd232c5dd1 100644 --- a/src/lib/unlang/edit.c +++ b/src/lib/unlang/edit.c @@ -97,36 +97,6 @@ static int tmpl_attr_from_result(TALLOC_CTX *ctx, map_t const *map, edit_result_ return -1; } - /* - * String outputs can be interpreted as attribute references. - * - * LHS of an assignment MUST be an attribute. The RHS - * MAY be an attribute, if the stars align. - */ - if (map && map->rhs) { - /* - * &foo := "bar" - * - * RHS can't be an attribute. - */ - if (map->rhs->quote != T_BARE_WORD) return 0; - - /* - * &foo := %{bin:0102030005060708} - * - * RHS is octets (or other non-string), and can't be an attribute references. - */ - if (box->type != FR_TYPE_STRING) return 0; - - /* - * @todo - arguably the assignment should be something like: - * - * &foo := &%{expansion} - * - * To say "yes, we really want the RHS to be an attribute reference". - */ - } - /* * Mash all of the results together. */ @@ -903,35 +873,6 @@ static int check_rhs(request_t *request, unlang_frame_state_edit_t *state, edit_ return next_map(request, state, current); } -/* - * We've expanded the RHS to a value, attribute reference, etc. Convert it to an attribute reference tmpl if necessary. - */ -static int expanded_rhs(request_t *request, unlang_frame_state_edit_t *state, edit_map_t *current) -{ - map_t const *map = current->map; - - /* - * The RHS is a list, go handle that. - */ - if (!map->rhs) { - return check_rhs(request, state, current); - } - - /* - * If the expansions is a bare xlat, then it can be - * interpreted as an attribute reference. - * - * In all other cases, the RHS value-box list is left alone. - */ - if (!tmpl_is_xlat(map->rhs) || (map->rhs->quote != T_BARE_WORD)) { - return check_rhs(request, state, current); - } - - if (tmpl_attr_from_result(state, map, ¤t->rhs, request) < 0) return -1; - - return check_rhs(request, state, current); -} - /* * The RHS map is a sublist. Go expand that by creating a child expansion context, and returning to the * main loop. @@ -1037,7 +978,7 @@ static int expand_rhs(request_t *request, unlang_frame_state_edit_t *state, edit if (rcode < 0) return -1; if (rcode == 1) { - current->func = expanded_rhs; + current->func = check_rhs; return 1; }