]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
don't auto-convert RHS xlats to attribute references
authorAlan T. DeKok <aland@freeradius.org>
Tue, 22 Nov 2022 12:15:23 +0000 (07:15 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 22 Nov 2022 12:15:23 +0000 (07:15 -0500)
if the caller cares, he can use

&foo := %{eval:%{xlat}}

If we care, we can add

&foo := &%{xlat}

src/lib/unlang/edit.c

index 601e7c820e27c49341174eaffec61165723f828d..ebd232c5dd1ba5e4ddad4b3aa3dfefc09c235bd0 100644 (file)
@@ -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, &current->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;
        }