acct_unique with more than one Class attribute

Brian Candler b.candler at pobox.com
Mon Mar 27 12:10:29 CEST 2017


On 27/03/2017 10:37, Andrea Gabellini wrote:
>
>
> I tried both &Class[*] and the foreach statement. The next problem is
> the string conversion. What happens:
>
> - &Class[*]:
> It returns all instances of the attribute separated with a comma. Only
> the first one is converted to a string.
Only if you write %{Class[*]} or %{&Class[*]}, i.e. you ask Freeradius 
to convert it into a string.

Don't do that. Try this:

if (&Class[*] =~ /pattern(.*)pattern/) {
     ... use %{1} to get the capture group
}

I think this should work if you are on FreeRADIUS 3.x.  That is, only 
the first match should be used.  (But I've not tested it myself)

> - foreach statement:
> "%{string:%{Foreach-Variable-0}}" results in an empty string
...
> (3) Mon Mar 27 11:33:31 2017: Debug:           EXPAND Foreach-Variable-0
> (3) Mon Mar 27 11:33:31 2017: Debug:              --> 0x54657374436c617373
That doesn't look empty to me. 54=T, 65=e, 63=s 74=t etc.

The underlying issue is that 'Class' is not a string attribute, so it's 
hard to treat it as such.  I have in the past modified the dictionary so 
that Class *is* a string.  But in general, it could contain binary data, 
and FreeRADIUS isn't great at handling that if the dictionary says the 
attribute is a String.

Regards,

Brian.


More information about the Freeradius-Users mailing list