RES: Old "problem" with backquote and Mikrotik-Rate-Limit (fixed)
Rafael Labiak Olivastro
rolivastro at hotmail.com
Fri Sep 28 15:33:10 CEST 2018
Perfect, fits like a glove. =)
I spent almost 3 days to figure out that way and now with just minutes you explain a much beter way, just the freeradius´s creator could be done this.
Thanks again, when you need something from Brazil let me know, maybe I can help you. 😉
De: Alan DeKok<mailto:aland at deployingradius.com>
Enviado:sexta-feira, 28 de setembro de 2018 09:06
Para: FreeRadius users mailing list<mailto:freeradius-users at lists.freeradius.org>
Assunto: Re: Old "problem" with backquote and Mikrotik-Rate-Limit (fixed)
On Sep 28, 2018, at 8:34 AM, Rafael Labiak Olivastro <rolivastro at hotmail.com> wrote:
> I was facing a problem with backquotes and the Mikrotik-Rate-Limit atribute, this problem happened when I put something like “%{sql: select....}” in the attribute´s value, everything worked fine BUT in the final result the backquotes is not removed, causing problems in the NAS.
If the value in SQL has back quotes, they can be removed. I'm not sure where the extra back quotes would come from.
> 1 – Create a new file called “/usr/bin/echo2” with following contents and make it executable (chmod 755 /usr/sbin/echo2):
>
> #!/bin/bash
> echo $1 | sed -r "s/\`//g"
>
> 2 – Edit file /etc/raddb/sites-available/default and ADD the following in the post-auth section:
>
> if (reply:Mikrotik-Rate-Limit =~ /.*\`$/i) {
> update reply {
> &Mikrotik-Rate-Limit := `/usr/bin/echo2 %{0}`
> }
There's a better solution. Just do this:
if (reply:Mikrotik-Rate-Limit =~ /\`(.*)\`$/i) {
update reply {
&Mikrotik-Rate-Limit := "%{1}"
}
}
You can do a regex match on just a substring, and then give that substring to an attribute.
It also avoids forking an external program, which is *slow*, and therefore fragile.
> Again, thanks a lot for the work with FreeRadius, you and your team deserve all my respects.
You're welcome. We try hard.
Alan DeKok.
-
List info/subscribe/unsubscribe? See https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.freeradius.org%2Flist%2Fusers.html&data=02%7C01%7C%7Ca547876a0a0e435bf1d808d625433f7d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636737368094638695&sdata=zvd76C9c3NhKljyF2Q9wU1VWdZiUfgUZ3l%2BkTWZJ41M%3D&reserved=0
More information about the Freeradius-Users
mailing list