]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Convert &Packet-Type to "%{Packet-Type}"
authorAlan T. DeKok <aland@freeradius.org>
Fri, 19 Jun 2015 02:43:39 +0000 (22:43 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 19 Jun 2015 02:45:03 +0000 (22:45 -0400)
Because the xlat will notice that it's a virtual attribute,
and call the expand function.  But the "find attribute in list"
code won't find the virtual attribute.

src/main/parser.c

index 7f7ca73bd408891d4eedd415353d69116d9e2c45..a94a0dd1627ca99cb160d6ce13d1a58edad9983b 100644 (file)
@@ -1004,6 +1004,26 @@ 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
                                 */
@@ -1162,7 +1182,6 @@ static ssize_t condition_tokenize(TALLOC_CTX *ctx, CONF_ITEM *ci, char const *st
                                        int hyphens = 0;
                                        bool may_be_attr = true;
                                        size_t i;
-                                       vp_tmpl_t *vpt;
                                        ssize_t attr_slen;
 
                                        /*