]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Allow virtual attrs in switch. Fixes #1240
authorAlan T. DeKok <aland@freeradius.org>
Wed, 16 Sep 2015 17:15:00 +0000 (13:15 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 16 Sep 2015 17:15:00 +0000 (13:15 -0400)
src/main/modcall.c
src/tests/keywords/switch-virtual [new file with mode: 0644]

index 6d440039bf699980c08710b2854f82d17b256539..4b45f6474156f8f98a3a592ffe820e134e36f708 100644 (file)
@@ -3639,6 +3639,14 @@ bool modcall_pass2(modcallable *mc)
                                goto do_children;
                        }
 
+                       /*
+                        *      Convert virtual &Attr-Foo to "%{Attr-Foo}"
+                        */
+                       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;
+                       }
+
                        /*
                         *      We may have: switch Foo-Bar {
                         *
diff --git a/src/tests/keywords/switch-virtual b/src/tests/keywords/switch-virtual
new file mode 100644 (file)
index 0000000..659604d
--- /dev/null
@@ -0,0 +1,23 @@
+#
+#  PRE: update switch
+#
+update control {
+       Cleartext-Password := 'hello'
+}
+
+#
+#  Virtual attribute references get mashed to xlats
+#
+switch &Packet-Type {
+       case Access-Request {
+               update reply {
+                       Filter-Id := "filter"
+               }
+       }
+
+       case {
+               update reply {
+                       Filter-Id := "fail"
+               }
+       }
+}
\ No newline at end of file