lpad on regular expression matches does not work

Tomasz Chiliński chilek at chilan.com
Thu Mar 4 16:51:27 CET 2021


W dniu 04.03.2021 16:26, Jorge Pereira napisał(a):
> Tomasz,

Guys,

thanks for all replies and clarifications!

I've also found code fragment which seems to register all xlat function 
handlers:

https://github.com/FreeRADIUS/freeradius-server/blob/90026932c8fe92751b1409129ad2dedf6bab1a24/src/lib/unlang/xlat_builtin.c#L3318-L3379

As I see some functions are quite old and they are treated as "legacy" 
ones - they don't
implement full symbol substitution, but only radius attributes?

> As Alan said, the current %{lpad:} (also the %{rpad:}) behaviour
> expects an attribute as you can see in
> https://github.com/FreeRADIUS/freeradius-server/blob/v3.0.x/raddb/mods-available/expr#L133
> 
> Therefore, you could try something like:
> 
>> if (&Calling-Station-Id && (&Calling-Station-Id =~
> /^${policy.mac-addr-regexp}$/i)) {
>     update control {
>        &Tmp-String-1 := “%{1}”
>        &Tmp-String-2 := “%{2}”
>        &Tmp-String-3 := “%{3}”
>        &Tmp-String-4 := “%{4}”
>        &Tmp-String-5 := “%{5}”
>        &Tmp-String-6 := “%{6}”
>     }
>     update request {
> 
>         &Calling-Station-Id := "%{toupper:%{lpad:&control:Tmp-String-1
> 2 0}:%{lpad:&control:Tmp-String-2 2 0}:%{lpad:&control:Tmp-String-3 2
> 0}:%{lpad:&control:Tmp-String-4 2 0}:%{lpad:&control:Tmp-String-5 2
> 0}:%{lpad:&control:Tmp-String-6 2 0}}"
>     }
>     updated
> } else {
> ...

Yeah, you're right. I considers such work-around and it could be 
effective.
Thanks for my thought confirmation!

Do "modern" xlat function support nested expressions?

-- 
Bests,
Tomasz Chiliński, Chilan
opiekun projektu LMS - https://lms.org.pl
kierownik projektu LMS Plus / LMS+ - https://lms-plus.org


More information about the Freeradius-Users mailing list