From: Alan T. DeKok Date: Wed, 16 Sep 2015 17:15:00 +0000 (-0400) Subject: Allow virtual attrs in switch. Fixes #1240 X-Git-Tag: release_3_0_10~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=019dcfe817a6fbe88093968cc4277fdd99dfade8;p=thirdparty%2Ffreeradius-server.git Allow virtual attrs in switch. Fixes #1240 --- diff --git a/src/main/modcall.c b/src/main/modcall.c index 6d440039bf6..4b45f647415 100644 --- a/src/main/modcall.c +++ b/src/main/modcall.c @@ -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 index 00000000000..659604d98c7 --- /dev/null +++ b/src/tests/keywords/switch-virtual @@ -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