Stripping prefix with unlang
Bernd
bernd at kroenchenstadt.de
Fri Mar 11 09:35:07 CET 2016
Am 2016-03-03 16:23, schrieb Alan DeKok:
> 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.
Thanks a lot, that works for me now. Sorry for the late reply, had to
head out for a few days.
> Alan DeKok.
Regards,
Bernd
More information about the Freeradius-Users
mailing list