]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
resolve the xlat
authorAlan T. DeKok <aland@freeradius.org>
Wed, 16 Sep 2020 02:36:14 +0000 (22:36 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 21 Sep 2020 16:17:21 +0000 (11:17 -0500)
after converting a virtual attribute to an xlat

src/lib/server/tmpl.c
src/lib/unlang/compile.c
src/lib/unlang/xlat_tokenize.c

index 9442687b562151f725b00c428fa668ed4e932d12..b92b1e08e388e32f1e582ddf3d67df24915abd36 100644 (file)
@@ -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;
index d6403d4cb74c53bc89df73e6576423cbe4c9ec17..661a9d5826dad385d675c1fcae7adf5dd28d3833 100644 (file)
@@ -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
index 6760e08542cf77f330ce40660bc1347ae2a36dde..3af2e6e83ee40934e51bdc301fac14e6d771782d 100644 (file)
@@ -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 */