Re: Simultaneous-Use For Group Using Unlang

2011-11-09 Thread Fajar A. Nugraha
On Thu, Nov 10, 2011 at 9:27 AM, Det Det  wrote:
> Hi,
> Where do I put this piece of code? Can I do this invocation in the authorize
> block? Or is it something I put in the radiusd.conf?

man unlang

"
Requests are processed through virtual servers (including the default
one), in the  sections  titled
   "authorize", "authenticate", "post-auth", "preacct",
"accounting", "pre-proxy", "post-proxy", and "session".
"

> And where do I put the
> custom procedure itself? Is it in /etc/freeradius/modules?

Alan is using an example where you have an sql procedure. If you don't
know what an sql procedure is, then you need to learn what that is
(which can be a steep learning curve).

The main point is if your exec-program-wait simply do ONE sql query,
then you can easily replace it using sql expansion. Use it to replace
your exec-program-wait (usually in authorize).

If your program currently uses some complex sql queries, then you need
to find some way to group them together so they can be invoked as one
query. One way to do that is using stored procedure. A documentation
for MySQL is here:
http://dev.mysql.com/doc/refman/5.5/en/stored-programs-views.html .
Since this is not freeradius-specific issue, if you need more info
about stored procedure you should ask in their respective list/forum.

-- 
Fajar
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


Re: Simultaneous-Use For Group Using Unlang

2011-11-09 Thread Det Det
Hi,

Where do I put this piece of code? Can I do this invocation in the authorize 
block? Or is it something I put in the radiusd.conf? And where do I put the 
custom procedure itself? Is it in /etc/freeradius/modules?

Sorry about this. I'm confused about the placement. First time to add a custom 
procedure. Possible to extend this example to show which codes go to which file?

Thanks a lot!
Det




From: Alan DeKok 
To: FreeRadius users mailing list 
Sent: Wednesday, November 9, 2011 9:57 PM
Subject: Re: Simultaneous-Use For Group Using Unlang

det.explo...@yahoo.com wrote:
> I'd like to implement this using unlang but not sure where to start. The part 
> that I am having difficulty is on where to create the procedure and how to 
> call the procedure. The rest of the things like the DB query I can reuse from 
> the existing program. I want to implement this using unlang to avoid having 
> to open a new MySQL connection.
> 
> Any example, I can follow?

  The SQL module supports string expansion.  The input strings are just
SQL statements.  The output is just a one-line string containing the
result of the SQL query.

  This means you can call SQL procedures directly from unlang:

    if ("%{sql: call procedure with args}" > 2) {
        ... more than 2 people logged in ..
    }

  Very simple!

  Alan DeKok.
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


Re: Simultaneous-Use For Group Using Unlang

2011-11-09 Thread Alan DeKok
det.explo...@yahoo.com wrote:
> I'd like to implement this using unlang but not sure where to start. The part 
> that I am having difficulty is on where to create the procedure and how to 
> call the procedure. The rest of the things like the DB query I can reuse from 
> the existing program. I want to implement this using unlang to avoid having 
> to open a new MySQL connection.
> 
> Any example, I can follow?

  The SQL module supports string expansion.  The input strings are just
SQL statements.  The output is just a one-line string containing the
result of the SQL query.

  This means you can call SQL procedures directly from unlang:

if ("%{sql: call procedure with args}" > 2) {
... more than 2 people logged in ..
}

  Very simple!

  Alan DeKok.
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


Simultaneous-Use For Group Using Unlang

2011-11-09 Thread det.explo...@yahoo.com
Hi,

I was able to implement simultaneous-use checking for a group using 
exec-program-wait attribute. So a user logging in which belongs to the group 
will be checked against that attribute. It is working but I worry that with too 
many connections coming from this group of users, it will exhaust the MySQL 
connection. Because the program used in exec-program-wait opens new connection 
to MySQL everytime. And even when the program closes the MySQL connection, the 
port for the connection will not be freed up immediately. It takes sometimes 
before the port is released. It stays in the close_wait status for sometime.

I'd like to implement this using unlang but not sure where to start. The part 
that I am having difficulty is on where to create the procedure and how to call 
the procedure. The rest of the things like the DB query I can reuse from the 
existing program. I want to implement this using unlang to avoid having to open 
a new MySQL connection.

Any example, I can follow?

Thanks a lot!
Det
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html