Another kludge that may be useful to someone:

I added some code to create a group maximum within the session database.
This required a modification to,, and
(If you used a different module it would need to be modified
as well)

Then within the <SessionDatabase> I use:

   GroupQuery someUniqueName 30 \
       select count(*) from radonline \
       where ('%{Called-Station-Id}'='XXXXXXX')

This would limit the number of connections to the phone number XXXXXXX to

You could add as many of these as you wanted and use whatever query
generated the necessary results.

********************************* - Add the following after the check for MaxSession:
    if ($p->code eq 'Access-Request' && $sessdb->groupexceeded($p))
        # Issue a denial and bomb out
        my $reason = "Group Maximum exceeded";
        &main::log($main::LOG_INFO, "Access rejected for $name: $reason");
                'Request Denied');
        $rp->addAttrByNum($Radius::Radius::REPLY_MESSAGE, $reason)
                if $self->{RejectHasReason};
        $p->{Client}->replyTo($rp, $p);

********************************* - add the following (this is probably not needed):

sub groupexceeded
    my ($self, $max, $name, $p) = @_;

    &main::log($main::LOG_ERR, "You did not override groupexceeded in 

********************************* - add the following:

    elsif ($keyword eq 'GroupQuery')
        my($id, $count, $q) = split(/\s+/, $value, 3);
        $self->{GroupQuery}{$id} = "$count:$q";

sub groupexceeded
    my ($self, $p) = @_;

    # (Re)-connect to the database if necessary, but dont let
    # a dead database prevent logins
    return 0
        if !$self->reconnect;

    my $count = 0; # Number of current simultaneous sessions for the user

    foreach $id (keys %{$self->{GroupQuery}})
        ($max, $q) = split(':', $self->{GroupQuery}{$id});

        $q = &main::format_special($q, $p);

        $sth = $self->prepareAndExecute($q);
        if (!$sth)
            return 0; # Dont let a dead database stop logins
        ($count) = $sth->fetchrow();
        return 1    if ($count > $max);
    return 0;

All improvements welcome.


Archive at
To unsubscribe, email '[EMAIL PROTECTED]' with
'unsubscribe radiator' in the body of the message.

Reply via email to