Stripping prefix with unlang

Alan DeKok aland at deployingradius.com
Thu Mar 3 16:23:29 CET 2016


On Mar 3, 2016, at 9:34 AM, Bernd <bernd at kroenchenstadt.de> wrote:
> 
> I am pulling my hears for two hours now. I'd like to strip a prefix off a request and I'm trying to use unlang in policy.d/filter to do that.
> 
>        if (User-Name =~ /adsl\-bla\/([^%%]+)%%adsl-bla.kroenchenstadt.de/) {

  That's good.

>                update request {
>                User-Name := "([^%%]+)%%adsl-sbt.kroenchenstadt.de/"

  That's not.  You're setting the value of User-Name to... a regular expression?  Why?

  You need to set it to the value captured from the regular expression.

> I just need to strip ``adsl-bla/'' off the login request.

	if (User-Name =~ /^adsl-\/(.+)$/) {
		update request {
			User-Name := "%{1}"
		}
	}

  i.e. you don't need to escape the "-".  You do need to escape the "/'.  And then you just grab everything to the right of that.

  Alan DeKok.




More information about the Freeradius-Users mailing list