]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
set output flags, and call resolution if needed
authorAlan T. DeKok <aland@freeradius.org>
Wed, 9 Feb 2022 20:53:09 +0000 (15:53 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 9 Feb 2022 20:53:09 +0000 (15:53 -0500)
src/bin/unit_test_module.c
src/lib/unlang/xlat_expr.c

index 9a94105f6f8666b6b8b48b40303a289cbfb8ee33..6d6dafb921f50bf30eaa2a908acd94d1209e52ac 100644 (file)
@@ -420,8 +420,9 @@ static bool do_xlats(fr_event_list_t *el, char const *filename, FILE *fp)
                        TALLOC_CTX              *xlat_ctx = talloc_init_const("xlat");
                        char                    *fmt = talloc_typed_strdup(xlat_ctx, input + 10);
                        xlat_exp_t              *head = NULL;
+                       xlat_flags_t            flags = { };
 
-                       slen = xlat_tokenize_ephemeral_expression(xlat_ctx, &head, el, NULL,
+                       slen = xlat_tokenize_ephemeral_expression(xlat_ctx, &head, el, &flags,
                                                                  &FR_SBUFF_IN(fmt, talloc_array_length(fmt) - 1),
                                                                  NULL,
                                                                  &(tmpl_rules_t) {
@@ -445,6 +446,12 @@ static bool do_xlats(fr_event_list_t *el, char const *filename, FILE *fp)
                                continue;
                        }
 
+                       if (xlat_resolve(&head, &flags, NULL) < 0) {
+                               talloc_free(xlat_ctx);
+                               snprintf(output, sizeof(output), "ERROR resolving xlat: %s", fr_strerror());
+                               continue;
+                       }
+
                        len = xlat_eval_compiled(output, sizeof(output), request, head, NULL, NULL);
                        if (len < 0) {
                                talloc_free(xlat_ctx);
index 6c84ca132f4dc976dc37beede7d96b85a688fd1f..5e034927ad5a8e5008463f77fe69c1023ceb73b6 100644 (file)
@@ -869,6 +869,8 @@ static ssize_t tokenize_regex(TALLOC_CTX *ctx, xlat_exp_t **head, UNUSED xlat_fl
        }
 
        *head = node;
+       xlat_flags_merge(flags, &node->flags);
+
        return fr_sbuff_used(&our_in);
 }
 #endif
@@ -1098,6 +1100,8 @@ done:
 
        fr_assert(node != NULL);
        *head = node;
+       xlat_flags_merge(flags, &node->flags);
+
        return fr_sbuff_set(in, &our_in);
 }