]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
ensure runtime_el is set
authorAlan T. DeKok <aland@freeradius.org>
Sat, 7 Oct 2023 18:18:34 +0000 (14:18 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 7 Oct 2023 18:18:34 +0000 (14:18 -0400)
and instantiate ephemeral xlats in tmpl_tokenize

src/lib/ldap/map.c
src/lib/server/tmpl_tokenize.c
src/lib/unlang/xlat_tokenize.c
src/modules/rlm_linelog/rlm_linelog.c

index 3467e49cc6a4d8582734983ffe16435ce6dada18..de9c1b74923382bbaef88f8c8808dc8844c61704 100644 (file)
@@ -72,6 +72,9 @@ int fr_ldap_map_getvalue(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *reques
                                        .list_def = tmpl_list(map->lhs),
                                        .prefix = TMPL_ATTR_REF_PREFIX_AUTO
                                },
+                               .xlat = {
+                                       .runtime_el = unlang_interpret_event_list(request),
+                               },
                                .at_runtime = true,
                        };
 
@@ -79,6 +82,9 @@ int fr_ldap_map_getvalue(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *reques
                                .attr = {
                                        .dict_def = request->dict
                                },
+                               .xlat = {
+                                       .runtime_el = lhs_rules.xlat.runtime_el,
+                               },
                                .at_runtime = true,
                        };
 
@@ -379,13 +385,16 @@ int fr_ldap_map_do(request_t *request,
                        map_t   *attr;
                        char            *value;
 
-                       tmpl_rules_t parse_rules = {
-                               .at_runtime = true,
+                       tmpl_rules_t const parse_rules = {
                                .attr = {
                                        .dict_def = request->dict,
                                        .list_def = request_attr_request,
                                        .prefix = TMPL_ATTR_REF_PREFIX_AUTO
-                               }
+                               },
+                               .xlat = {
+                                       .runtime_el = unlang_interpret_event_list(request),
+                               },
+                               .at_runtime = true,
                        };
 
                        value = fr_ldap_berval_to_string(request, values[i]);
index a46723bfc8a03c350525449f33cc1fe6764417e9..e15247659c04048b5902a8f313dbf3ecb9979003 100644 (file)
@@ -3277,9 +3277,18 @@ fr_slen_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out,
                 *      Ensure any xlats produced are bootstrapped
                 *      so that their instance data will be created.
                 */
-               if (!t_rules->at_runtime && head && (xlat_bootstrap(head) < 0)) {
-                       fr_strerror_const("Failed to bootstrap xlat");
-                       FR_SBUFF_ERROR_RETURN(&our_in);
+               if (head) {
+                       int rcode;
+
+                       if (!t_rules->at_runtime) {
+                               rcode = xlat_bootstrap(head);
+                       } else {
+                               rcode = xlat_instantiate_ephemeral(head, t_rules->xlat.runtime_el);
+                       }
+                       if (rcode < 0) {
+                               fr_strerror_const("Failed to bootstrap xlat");
+                               FR_SBUFF_ERROR_RETURN(&our_in);
+                       }
                }
 
                if (xlat_needs_resolving(head)) UNRESOLVED_SET(&type);
index f679ebfec5818d48962f21f6ee562d657a5cc7ae..c362907f2131591237856c4fa0ea1aa98a4f719f 100644 (file)
@@ -1865,7 +1865,10 @@ fr_slen_t xlat_tokenize(TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sbuff_t *in,
        xlat_exp_head_t *head;
 
        MEM(head = xlat_exp_head_alloc(ctx));
-       if (t_rules) head->dict = t_rules->attr.dict_def;
+       if (t_rules) {
+               head->dict = t_rules->attr.dict_def;
+               fr_assert(!t_rules->at_runtime || t_rules->xlat.runtime_el); /* if it's at runtime, we need an event list */
+       }
 
        fr_strerror_clear();    /* Clear error buffer */
 
index 6776fd1159a4112d6d3bcdd68a8f46b3223c5c57..2d67774a67d0cf9983302ba01600b8593d95848b 100644 (file)
@@ -670,6 +670,9 @@ static unlang_action_t CC_HINT(nonnull) mod_do_linelog(rlm_rcode_t *p_result, mo
                                                        .allow_unknown = true,
                                                        .allow_unresolved = false,
                                                },
+                                               .xlat = {
+                                                       .runtime_el = unlang_interpret_event_list(request),
+                                               },
                                                .at_runtime = true
                                         });
                if (!vpt) {