Multiple fieldnames in SQL query, was: Perl vs. python vs. Lua?

Dom Latter freeradius-users at latter.org
Thu Apr 12 15:14:07 CEST 2018


On 02/27/18 14:09, Alan DeKok wrote:
> Use the native DB query functions in FreeRADIUS.  It's MUCH faster
> that way.
> 
> i.e. do any and all DB queries via "update" sections, and assign the
> values to temporary attributes.  Then, run the *logic* in Python.
> i.e. have the python code do if / then / else checks, but don't have
> it to DB connectivity.

Hi,

we are trying to pursue this approach.  I am trying to figure out how to
get multiple values out of the database.

I have got this:

update control {
	DL-Device-Vendor := "%{sql:SELECT devicevendor FROM userinfo   \
            WHERE username='%{request:User-Name}' }"
}

(NB no line break in reality).

working inside a post-auth block inside /etc/freeradius/sites-enabled
/default.  (In that I run freeradius -X and see the query running
in the debug output).

Now what I want is to run a longer and more complicated query and set up
multiple attributes.  (Our current post-auth script pulls some 13 items
out of the database).

The only thing I have found on this so far is this page on github:
https://github.com/FreeRADIUS/freeradius-server/issues/984


So I tried this :

map sql "SELECT devicevendor FROM userinfo WHERE \
           username='{request:User-Name}'" {
                 XL-Device-Vendor := 'devicevendor'
}

and got this error:
  Expecting section start brace '{' after "map sql"
(Also tried with 'mysql' rather than 'sql' - which
should it be, anyway?)

How do I go about this?


More information about the Freeradius-Users mailing list