[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freeradius-users
Subject:    Re: Old "problem" with backquote and Mikrotik-Rate-Limit (fixed)
From:       Alan DeKok <aland () deployingradius ! com>
Date:       2018-09-28 13:06:09
Message-ID: 1316D9D0-53B8-433B-8E3F-7C7D68326D12 () deployingradius ! com
[Download RAW message or body]

On Sep 28, 2018, at 8:34 AM, Rafael Labiak Olivastro <rolivastro@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 http://www.freeradius.org/list/users.html


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic