If statement regex match with multiple similar attributes

jberry at plus.net jberry at plus.net
Thu Jan 8 11:03:07 CET 2015

> Is upgrading your FreeRADIUS a possibility? Starting from version 3,
> there is a foreach statement in unlang, that can loop through the

Sadly not. We are planning to do this but have custom modules at the
moment which need to be purged/rewritten but this is good knowledge for
when we do!

> Otherwise, if it is always the second Class, you could use
> %{reply:Class[1]}, but this feels a bit like a hack. There are some
> hints about this in the man page of unlang.

I will have to go with this for now. I did find a further improvement to
this that works so replying to the list in case anyone else finds it

  if( "%{reply:Class[*]}" =~ /.*0x434653494421.*/ ) {
    update reply {

This assesses the array containing all Class attrs as a string (I think)
so providing you are looking for something you know is going to be unique
it works a treat:

  ++? if ("%{reply:Class[*]}" =~ /.*0x434653494421.*/ )
  expand: %{reply:Class[*]} ->
  ? Evaluating ("%{reply:Class[*]}" =~ /.*0x434653494421.*/) -> TRUE

P.s. Sorry if I messed up anyones threading, had the list in digest mode
and couldn¹t work out how to reply!

Many thinks

Josh Berry
Senior Systems Engineer
Plusnet PLC | www.plus.net
Phone: 01142 733547
Registered Office: The Balance | 2 Pinfold Street | Sheffield | S1 2GU
Registered in England no: 3279013

More information about the Freeradius-Users mailing list