Allow checks for existence of virtual attrs. Fixes #1265
authorAlan T. DeKok <aland@freeradius.org>
Wed, 23 Sep 2015 17:36:54 +0000 (13:36 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 23 Sep 2015 17:36:54 +0000 (13:36 -0400)
src/main/modcall.c
src/tests/keywords/virtual-exists [new file with mode: 0644]

index 4b45f64..28061f7 100644 (file)
@@ -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 (file)
index 0000000..7a8e8f3
--- /dev/null
@@ -0,0 +1,12 @@
+#
+#  PRE: update if
+#
+update control {
+       Cleartext-Password := 'hello'
+}
+
+if (&Client-Shortname) {
+       update reply {
+               Filter-Id := "filter"
+       }
+}