]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
More fixes for virtual attributes
authorAlan T. DeKok <aland@freeradius.org>
Wed, 23 Sep 2015 18:23:04 +0000 (14:23 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 23 Sep 2015 18:23:04 +0000 (14:23 -0400)
src/main/modcall.c
src/tests/keywords/virtual-rhs [new file with mode: 0644]

index 28061f7be7d39e6daa87c6746c4092aaf5c52b16..d02b0031c86cb30c0d081a38b6910a1cf33161f6 100644 (file)
@@ -3437,6 +3437,15 @@ static bool pass2_callback(void *ctx, fr_cond_t *c)
                vpt->type = TMPL_TYPE_XLAT_STRUCT;
        }
 
+       /*
+        *      Convert RHS to expansions, too.
+        */
+       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;
+       }
+
        /*
         *      @todo v3.1: do the same thing for the RHS...
         */
@@ -3789,6 +3798,14 @@ bool modcall_pass2(modcallable *mc)
                                }
                        }
 
+                       /*
+                        *      Virtual attribute fixes for "case" statements, too.
+                        */
+                       if ((g->vpt->type == TMPL_TYPE_ATTR) && g->vpt->tmpl_da->flags.virtual) {
+                               g->vpt->tmpl_xlat = xlat_from_tmpl_attr(g->vpt, g->vpt);
+                               g->vpt->type = TMPL_TYPE_XLAT_STRUCT;
+                       }
+
                        if (!modcall_pass2(g->children)) return false;
                        g->done_pass2 = true;
                        break;
diff --git a/src/tests/keywords/virtual-rhs b/src/tests/keywords/virtual-rhs
new file mode 100644 (file)
index 0000000..0d21e7f
--- /dev/null
@@ -0,0 +1,16 @@
+#
+#  PRE: update if
+#
+update control {
+       Cleartext-Password := 'hello'
+}
+
+update request {
+       Tmp-String-0 := "<UNKNOWN-CLIENT>"
+}
+
+if (&Tmp-String-0 == &Client-Shortname) {
+       update reply {
+               Filter-Id := "filter"
+       }
+}