From: Alan T. DeKok Date: Wed, 16 Sep 2020 02:36:14 +0000 (-0400) Subject: resolve the xlat X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5dd97f5f1b31892e5ca80596ac42c5bc8a2eaeb;p=thirdparty%2Ffreeradius-server.git resolve the xlat after converting a virtual attribute to an xlat --- diff --git a/src/lib/server/tmpl.c b/src/lib/server/tmpl.c index 9442687b562..b92b1e08e38 100644 --- a/src/lib/server/tmpl.c +++ b/src/lib/server/tmpl.c @@ -3185,6 +3185,8 @@ int tmpl_attr_to_xlat(TALLOC_CTX *ctx, tmpl_t **vpt_p) return -1; } + if (vpt->data.xlat.flags.needs_resolving) vpt->type |= TMPL_FLAG_UNRESOLVED; + *vpt_p = vpt; return 0; diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index d6403d4cb74..661a9d5826d 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -161,9 +161,15 @@ static bool pass2_fixup_tmpl(TALLOC_CTX *ctx, CONF_ITEM const *ci, tmpl_t **vpt_ * Convert virtual &Attr-Foo to "%{Attr-Foo}" */ if (tmpl_is_attr(vpt) && tmpl_da(vpt)->flags.virtual) { - if (tmpl_attr_to_xlat(ctx, vpt_p) < 0) return false; - return true; - } + if (tmpl_attr_to_xlat(ctx, vpt_p) < 0) { + return false; + } + + /* + * The VPT has been rewritten, so use the new one. + */ + vpt = *vpt_p; + } /* it's now xlat, so we need to resolve it. */ /* * Fixup any other tmpl types diff --git a/src/lib/unlang/xlat_tokenize.c b/src/lib/unlang/xlat_tokenize.c index 6760e08542c..3af2e6e83ee 100644 --- a/src/lib/unlang/xlat_tokenize.c +++ b/src/lib/unlang/xlat_tokenize.c @@ -1515,10 +1515,16 @@ int xlat_resolve(xlat_exp_t **head, xlat_flags_t *flags, bool allow_unresolved) case XLAT_VIRTUAL_UNRESOLVED: { xlat_t *func; + char const *name; - fr_assert(node->attr->type == TMPL_TYPE_ATTR_UNRESOLVED); + if (node->attr->type == TMPL_TYPE_ATTR_UNRESOLVED) { + name = tmpl_attr_unresolved(node->attr); + } else { + fr_assert(node->attr->type == TMPL_TYPE_ATTR); + name = tmpl_da(node->attr)->name; + } - func = xlat_func_find(tmpl_attr_unresolved(node->attr), -1); + func = xlat_func_find(name, -1); if (func) { xlat_exp_set_type(node, XLAT_VIRTUAL); node->attr = node->attr; /* Shift to the right location */