]> git.entuzijast.net Git - freeradius-dialup-admin.git/commitdiff
* Change log_badlogins to use the mysql binary instead of the DBI module. That way...
authorkkalev <kkalev>
Fri, 3 May 2002 22:10:54 +0000 (22:10 +0000)
committerkkalev <kkalev>
Fri, 3 May 2002 22:10:54 +0000 (22:10 +0000)
  and we don't need to bother with connection maintainance (dead mysql connections etc).
* Add a few comments in  rlm_ippool.c

Changelog
README
bin/log_badlogins

index ec3f690581a4a077ac248011218b08c73f0b3d1c..7275a739eb3fe11b10173841abd6efa6903df5c9 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -2,8 +2,10 @@ Ver 1.30:
 * Add limit of results returned in accounting.php3
 * Fix a bug in time2strclock() in lib/functions.php3. Seconds ammount more than 9 would not show.
   Bug noted by Timophey <bcloud@mail.ru>
-* Reaarange a few things in user_admin. Put Subscription Analysis and 'Account Status' second. Make a
+* Reaarange a few things in user_admin. Put Subscription Analysis first and 'Account Status' second. Make a
   few things bold.
+* Change log_badlogins to use the mysql binary instead of the DBI module. That way we don't have any dependencies
+  and we don't need to bother with connection maintainance (dead mysql connections etc).
 Ver 1.29:
 * Add general_ld_library_path directive and set LD_LIBRARY_PATH accordingly (used in snmpfinger and
   radaclient).
diff --git a/README b/README
index 5f104c4e51cf8685d16d527499a5b49ec6292d40..a106ef8e750761d2bca80f657f020d6526ec8395 100644 (file)
--- a/README
+++ b/README
@@ -13,6 +13,8 @@ There are also a few more things included:
   invalid-user, outside of allowed login time  and multiple-login cases to the radacct table with
   acctstarttime=acctstoptime, acctsessiontime=0 and acctterminatecause containing the reason.
   If the failing module sent back a module message then it will also appear in the terminate cause.
+  You will need to setup the $mysql and $tmpfile variables to suite your mysql installation and needs.
+  Perl module Date::Manip is needed by the script.
 * bin/clean_radacct: It will delete all entries in the radacct table with a starttime > 1 day and
   stoptime = 0. It will not do an harm even if it deletes valid entries since radiusd will fall
   back to insert if update fails.
index 9018eecd2633ee8e93f9213b60dd52674da947a5..2184406b96d2abdcfb5d98b95057bd08ca7d1a16 100755 (executable)
@@ -1,5 +1,4 @@
 #!/usr/bin/perl
-use DBI;
 
 use Date::Manip qw(ParseDate UnixDate);
 $|=1;
@@ -7,6 +6,8 @@ $|=1;
 $file=shift||'none';
 $conf=shift||'/src/cvs/radiusd/dialup_admin/conf/admin.conf';
 $domain='company.com';
+$mysql='/usr/local/mysql/bin/mysql';
+$tmpfile='/tmp/mysql.input';
 
 open CONF, "<$conf"
        or die "Could not open configuration file\n";
@@ -20,9 +21,8 @@ while(<CONF>){
        $sql_accounting_table = $val if ($key eq 'sql_accounting_table');
 }
 close CONF;
+$pass = ($sql_password ne '') ? "-p$sql_password" : '';
 
-$dbh = DBI->connect("DBI:mysql:$sql_database:$sql_server","$sql_username","$sql_password") 
-       or die "Could not connect to SQL database: $DBI::errtstr\n";
 open LOG, "<$file"
        or die "Could not open file $file\n";
 seek LOG, 0, 2;
@@ -78,11 +78,14 @@ for(;;){
                                $addr = gethostbyname $nas;
                                ($a,$b,$c,$d)=unpack('C4',$addr);
                                $addr = "$a.$b.$c.$d";
-$dbh->do("INSERT INTO $sql_accounting_table (UserName,NASIPAddress,NASPortId,AcctStartTime,AcctStopTime,AcctSessionTime,AcctInputOctets,AcctOutputOctets,CallingStationId,AcctTerminateCause) VALUES ('$user','$addr','$port','$time','$time','0','0','0','$caller','$cause');");
+                               open TMP, ">$tmpfile"
+                                       or die "Could not open temporary file\n";
+                               print TMP "INSERT INTO $sql_accounting_table (UserName,NASIPAddress,NASPortId,AcctStartTime,AcctStopTime,AcctSessionTime,AcctInputOctets,AcctOutputOctets,CallingStationId,AcctTerminateCause) VALUES ('$user','$addr','$port','$time','$time','0','0','0','$caller','$cause');";
+                               close TMP;
+                               `$mysql -h$sql_server -u$sql_username $pass $sql_database <$tmpfile`;
                        }
                }
        }
        sleep 2;
        seek LOG,0,1;
 }
-$dbh->disconnect();