help-gnu-radius
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gnu-radius] Executing more than one SQL query when recording a


From: Sergey Poznyakoff
Subject: Re: [Help-gnu-radius] Executing more than one SQL query when recording acct stop information
Date: Sat, 27 Sep 2003 13:13:27 +0300

Steve Horan <address@hidden> wrote:

> Is there an easy way of doing this out-of-the-box, or do I need to
> work some magic with rewrite/guile?

Yes, for the time being you will have to use a Guile extension
procedure to do so. In few words, it will look as follows:

1) Write an appropriate Scheme accounting procedure. The description
of the Scheme accounting interface is available at

http://www.gnu.org/software/radius/manual/html_chapter/radius_11.html#SEC200

Basically, it shuld build SQL request(s) and execute it/them via
radius-sql-query function, more or less like that:

(define (acct req)
 "Performs extended SQL accounting.
Arguments: REQ - the incoming request
Return: #t on success"
 (and (radius-sql-query SQL_ACCT (build-sql-query-1 req))
      (radius-sql-query SQL_ACCT (build-sql-query-2 req))))

where the functions (build-sql-query-1) and (build-sql-query-2) are
supposed to create the needed SQL queries. Notice, that you can't
feed to radius-sql-query two queries separated by ';' since the
libmysqlclient library is currently not able to handle that.
The function (radius-sql-query) returns #f on failure or a list
of retrieved tuple on success. If the query does not return any tuples,
(e.g. UPDATE, REPLACE, etc.), the function will return an empty list.


2) Add the invocation of (acct) to your radius database. This is
achieved by adding

         Scheme-Acct-Procedure = acct

to the right-hand side of an appropriate raddb/hints entry.

3) Store the file containing the definition of (acct) somewhere in
your %load-path% and configure the Guile interface in your raddb/config:

guile {
      load-path "directory/where/you/stored/it";
      load "acct.scm";
};

That's all :)

The built-in support for the multiple queries will appear in the next
release of Radius. 

Regards,
Sergey




reply via email to

[Prev in Thread] Current Thread [Next in Thread]