From: Alan T. DeKok Date: Wed, 9 Feb 2022 20:53:09 +0000 (-0500) Subject: set output flags, and call resolution if needed X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67ff3dd8522f2bee9d362513f1b72408114df7a7;p=thirdparty%2Ffreeradius-server.git set output flags, and call resolution if needed --- diff --git a/src/bin/unit_test_module.c b/src/bin/unit_test_module.c index 9a94105f6f8..6d6dafb921f 100644 --- a/src/bin/unit_test_module.c +++ b/src/bin/unit_test_module.c @@ -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); diff --git a/src/lib/unlang/xlat_expr.c b/src/lib/unlang/xlat_expr.c index 6c84ca132f4..5e034927ad5 100644 --- a/src/lib/unlang/xlat_expr.c +++ b/src/lib/unlang/xlat_expr.c @@ -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); }