From: Alan T. DeKok Date: Wed, 23 Sep 2015 17:36:54 +0000 (-0400) Subject: Allow checks for existence of virtual attrs. Fixes #1265 X-Git-Tag: release_3_0_10~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4cf81d48ff443806ee4ab69d5c3f635740109071;p=thirdparty%2Ffreeradius-server.git Allow checks for existence of virtual attrs. Fixes #1265 --- diff --git a/src/main/modcall.c b/src/main/modcall.c index 4b45f647415..28061f7be7d 100644 --- a/src/main/modcall.c +++ b/src/main/modcall.c @@ -3208,6 +3208,16 @@ static bool pass2_callback(void *ctx, fr_cond_t *c) if (!pass2_fixup_undefined(c->ci, c->data.vpt)) return false; c->pass2_fixup = PASS2_FIXUP_NONE; } + + /* + * Convert virtual &Attr-Foo to "%{Attr-Foo}" + */ + vpt = c->data.vpt; + 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; + } + return true; } diff --git a/src/tests/keywords/virtual-exists b/src/tests/keywords/virtual-exists new file mode 100644 index 00000000000..7a8e8f30f04 --- /dev/null +++ b/src/tests/keywords/virtual-exists @@ -0,0 +1,12 @@ +# +# PRE: update if +# +update control { + Cleartext-Password := 'hello' +} + +if (&Client-Shortname) { + update reply { + Filter-Id := "filter" + } +}