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

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


On 12/04/18 14:53, Alan DeKok wrote:

Thanks for the swift repsonse.

> On Apr 12, 2018, at 9:14 AM, Dom Latter <freeradius-users at latter.org> wrote:
>> we are trying to pursue this approach.  I am trying to figure out how to
>> get multiple values out of the database.
> 
>    v3 doesn't really support that well.
> 
>> The only thing I have found on this so far is this page on github:
>> https://github.com/FreeRADIUS/freeradius-server/issues/984
> 
>    Which as the comments say, was done in 3.1.x (now v4).  It's not available in v3.

Ah, I made the rash assumption that anything mentioned then would by
now be current - but I now understand that v4 is a big rewrite.

>> How do I go about this?
> 
>    You might need to just keep using Python.

Well, we are currently using exec to run a PHP script which doesn't seem
to be a great idea.

So the plan was to move to Perl; but if we did that and ran our mysql 
queries inside a perl script would we still have the performance issues?

I am beginning to think that we can construct a (rather complicated)
query that will return the VLAN that needs to be assigned, or 0 to
indicate rejection, or a magic number that will indicate further
processing required, and use unlang to act appropriately (and call
either a PHP script or in due course a perl script).

The vast majority of requests would fall into the first two camps.

So roughly speaking it would look a bit like this (consider this
pseudo-code!)

update control {
   Vlan-Value := "%{sql:SELECT .... as vlan FROM .... WHERE 
username='%{request:User-Name}' }"
}

if ( &Vlan-Value == 9999 ) {
   custom_module
}
else if ( &Vlan-Value > 0 ) {
   update reply {
     Tunnel-Private-Group-Id := Vlan-Value
     # some more attributes here
   }
}
else {
   reject
}

Although rather than a select statement I think it would be a stored
procedure.


More information about the Freeradius-Users mailing list