From 4cf81d48ff443806ee4ab69d5c3f635740109071 Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Wed, 23 Sep 2015 13:36:54 -0400 Subject: [PATCH] Allow checks for existence of virtual attrs. Fixes #1265 --- src/main/modcall.c | 10 ++++++++++ src/tests/keywords/virtual-exists | 12 ++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/tests/keywords/virtual-exists diff --git a/src/main/modcall.c b/src/main/modcall.c index 4b45f64..28061f7 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 0000000..7a8e8f3 --- /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" + } +} -- 2.1.4