(RADIATOR) SQLRADIUS patch

Alexander Mayrhofer axelm at nic.at
Tue Aug 5 05:04:09 CDT 2003


Hi,

I've done a small patch to the SQLRADIUS module, which helps in certain 
query situations. The patch (see below for a diff) adds the parameter:

StartHost [integer]   (Default: 1)

to the <AuthBy SQLRADIUS> section. It is useful in situations where you
don't want the local counter variable %0 to start with 1, the most
obvious one being

HostSelect SELECT HOST, SECRET FROM radius_servers WHERE realm='%R' \
	ORDER BY priority ASC OFFSET %0 LIMIT 1

which currently makes Radiator to miss the first row (it would start
with " ... OFFSET 1 LIMIT 1"). Setting "StartHost" to 0 remedies that
issue.

I'd like one of the Radiator developers to screen my patch, feel free to
integrate it into the mainstream source if it qualifies.

cheers

Alex Mayrhofer
nic.at


--- AuthSQLRADIUS.pm.orig	Tue Aug  5 11:06:23 2003
+++ AuthSQLRADIUS.pm	Tue Aug  5 11:28:33 2003
@@ -16,6 +16,7 @@
 %Radius::AuthSQLRADIUS::ConfigKeywords = 
     ('HostSelect'    => 'string',
      'NumHosts'      => 'integer',
+     'StartHost'     => 'integer',
      'HostColumnDef' => 'stringhash',
      );
 
@@ -33,6 +34,7 @@
 SERVERHASBROKENADDRESSES, IGNOREREPLYSIGNATURE, FAILUREPOLICY from RADSQLRADIUS
 where TARGETNAME=\'%R\'';
     $self->{NumHosts} = 2; # Number of hosts (primary and secodary) per realm
+    $self->{StartHost} = 1; # First host number
 }
 
 #####################################################################
@@ -45,12 +47,21 @@
 {
     my ($self, $fp, $p) = @_;
 
+    # initialize or increment hostCounter 
+    if (defined($fp->{hostCounter})) 
+    {
+        $fp->{hostCounter}++;
+    }
+    else 
+    {
+        $fp->{hostCounter} = $self->{StartHost};
+    }
+
     # If they have already tried to send this too many times, and there
     # are no more hosts to send to take the policy from the database
     # This standard table has space for 2 hosts. Adjust this if necessary
-    return if ($fp->{hostCounter} >= $self->{NumHosts});
+    return if ($fp->{hostCounter} > $self->{NumHosts});
 
-    $fp->{hostCounter}++;
     my $q = &Radius::Util::format_special
 	($self->{HostSelect}, $p, undef, $fp->{hostCounter});
 	

===
Archive at http://www.open.com.au/archives/radiator/
Announcements on radiator-announce at open.com.au
To unsubscribe, email 'majordomo at open.com.au' with
'unsubscribe radiator' in the body of the message.


More information about the radiator mailing list