> > I notice that recently a %{integer:...} expansion was added. Is there
> > perhaps a case for a corresponding %{string:...} expansion?
> 
>   Yes.
> 
>   Editing the dictionaries is not recommended, as it can have additional
> side effects.  Adding %{string:Class} is pretty specific.

OK, I've had a go at a patch. You can find it at
https://github.com/candlerb/freeradius-server/tree/candlerb/string_expansion

Aside: I guess you can't use this if you have an 'octets' value with an
embedded null. If I set
        Class = 0x666f6f00626172
then Reply-Message = "%{string:Class}" expands to
        Reply-Message = "foo"

Also, while doing this I also discovered a bug in the %{integer:...}
expansion: it will cause freeradius to segfault if the vp is known in the
dictionary but is not present in the request (radius_get_vp will return true
but set vp to NULL).  The fix is also in that branch, but I'll post it here
too:

diff --git a/src/main/xlat.c b/src/main/xlat.c
index 0a02064..f1818e1 100644
--- a/src/main/xlat.c
+++ b/src/main/xlat.c
@@ -420,7 +420,7 @@ static size_t xlat_integer(void *instance, REQUEST *request,
 
        while (isspace((int) *fmt)) fmt++;
 
-       if (!radius_get_vp(request, fmt, &vp)) {
+       if (!radius_get_vp(request, fmt, &vp) || !vp) {
                *out = '\0';
                return 0;
        }

Regards,

Brian.
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Reply via email to