]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Move virtual re-write to pass2 callback
authorAlan T. DeKok <aland@freeradius.org>
Fri, 19 Jun 2015 16:01:49 +0000 (12:01 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 19 Jun 2015 16:01:49 +0000 (12:01 -0400)
So that the main parser has the correct data

src/main/modcall.c
src/main/parser.c

index 3e5a824cc276c3db682be1b94e5a6892acfdcd31..2f77906a1caf6761f3df086c7ec47464fdfe4a14 100644 (file)
@@ -3126,6 +3126,7 @@ static bool pass2_fixup_undefined(CONF_ITEM const *ci, vp_tmpl_t *vpt)
 static bool pass2_callback(UNUSED void *ctx, fr_cond_t *c)
 {
        vp_map_t *map;
+       vp_tmpl_t *vpt;
 
        if (c->type == COND_TYPE_EXISTS) {
                if (c->data.vpt->type == TMPL_TYPE_XLAT) {
@@ -3250,7 +3251,6 @@ check_paircmp:
            (strncmp(map->lhs->name, "Foreach-Variable-", 17) == 0)) {
                char *fmt;
                ssize_t slen;
-               vp_tmpl_t *vpt;
 
                fmt = talloc_asprintf(map->lhs, "%%{%s}", map->lhs->name);
                slen = tmpl_afrom_str(map, &vpt, fmt, talloc_array_length(fmt) - 1,
@@ -3283,6 +3283,23 @@ check_paircmp:
        rad_assert(map->lhs->type != TMPL_TYPE_REGEX);
 #endif
 
+       /*
+        *      Convert &Packet-Type to "%{Packet-Type}", because
+        *      these attributes don't really exist.  The code to
+        *      find an attribute reference doesn't work, but the
+        *      xlat code does.
+        */
+       vpt = c->data.map->lhs;
+       if ((vpt->type == TMPL_TYPE_ATTR) && vpt->tmpl_da->flags.virtual) {
+               if (!c->cast) c->cast = vpt->tmpl_da;
+               vpt->tmpl_xlat = xlat_from_tmpl_attr(vpt, vpt);
+               vpt->type = TMPL_TYPE_XLAT_STRUCT;
+       }
+
+       /*
+        *      @todo v3.1: do the same thing for the RHS...
+        */
+
        /*
         *      Only attributes can have a paircompare registered, and
         *      they can only be with the current REQUEST, and only
index a94a0dd1627ca99cb160d6ce13d1a58edad9983b..67329b2339fb7edf76550419a3818ec0f90f6574 100644 (file)
@@ -1006,24 +1006,6 @@ static ssize_t condition_tokenize(TALLOC_CTX *ctx, CONF_ITEM *ci, char const *st
                        } else {
                                vp_tmpl_t *vpt;
 
-                               /*
-                                *      Convert &Packet-Type to "%{Packet-Type}", because
-                                *      these attributes don't really exist.  The code to
-                                *      find an attribute reference doesn't work, but the
-                                *      xlat code does.
-                                */
-                               vpt = c->data.map->lhs;
-                               if ((vpt->type == TMPL_TYPE_ATTR) && vpt->tmpl_da->flags.virtual) {
-                                       vpt->tmpl_xlat = xlat_from_tmpl_attr(vpt, vpt);
-                                       vpt->type = TMPL_TYPE_XLAT_STRUCT;
-                               }
-
-                               vpt = c->data.map->rhs;
-                               if ((vpt->type == TMPL_TYPE_ATTR) && vpt->tmpl_da->flags.virtual) {
-                                       vpt->tmpl_xlat = xlat_from_tmpl_attr(vpt, vpt);
-                                       vpt->type = TMPL_TYPE_XLAT_STRUCT;
-                               }
-
                                /*
                                 *      Two attributes?  They must be of the same type
                                 */