lpad on regular expression matches does not work

Alan DeKok aland at deployingradius.com
Thu Mar 4 15:13:41 CET 2021


> On Mar 4, 2021, at 5:13 AM, Tomasz ChiliƄski via Freeradius-Users <freeradius-users at lists.freeradius.org> wrote:
> rewrite_calling_station_id {
> 	if (&Calling-Station-Id && (&Calling-Station-Id =~ /^${policy.mac-addr-regexp}$/i)) {
> 		update request {
> 			&Calling-Station-Id := "%{toupper:%{lpad:%{1} 2 0}:%{lpad:%{2} 2 0}:%{lpad:%{3} 2 0}:%{lpad:%{4} 2 0}:%{lpad:%{5} 2 0}:%{lpad:%{6} 2 0}}"

  lpad takes attributes as the first argument, not strings.

> And here's surprise - lpad expression function handles only attribute parameters (ex. {lpad:&User-Name 100 0}),
> but not regexp matches. What am I doing wrong?

  You're not passing an attribute.

  It's probably not too difficult to add the capability to do expansions.  As always, patches are welcome.

  Alan DeKok.




More information about the Freeradius-Users mailing list