* Update the FAQ with an entry about the Online Users page not showing anything.
* Update the FAQ with an entry about sessions.
* Allow the user to add extra attributes in the test user page
+* Add a few comments in log_badlogins, support auth logs containing the password, work nice when the client
+ is localhost, add an option to scan the whole radius.log and add failed logins in the sql database (can be
+ used for initialization).
Ver 1.59:
* Small html fixes in user_edit.php3 and password.php3
* Show number of failed logins in the last 7 days in the user admin page
#!/usr/bin/perl
+#
+# Log failed logins in the sql database
+# Works only with mysql
+# It will read the sql parameters from the admin.conf file
+#
+# Usage:
+# log_badlogins <radius.log> [<admin.conf>] [all]
+#
+# Defaults:
+# radius.log: none
+# admin.conf: /usr/local/dialup_admin/conf/admin.conf
+# all: no. Go to the end of the file. Don't read it all.
use Date::Manip qw(ParseDate UnixDate);
$|=1;
$file=shift||'none';
-$conf=shift||'/src/cvs/radiusd/dialup_admin/conf/admin.conf';
+$conf=shift||'/usr/local/dialup_admin/conf/admin.conf';
+$all_file=shift||'no';
+#
+#
+# CHANGE THESE TO MATCH YOUR SETUP
+#
$domain='company.com';
$mysql='/usr/local/mysql/bin/mysql';
$tmpfile='/tmp/mysql.input';
+#
+#
open CONF, "<$conf"
or die "Could not open configuration file\n";
open LOG, "<$file"
or die "Could not open file $file\n";
-seek LOG, 0, 2;
+
+seek LOG, 0, 2 if ($all_file eq 'no');
for(;;){
while(<LOG>){
$do=0;
($year,$mon,$mday,$hour,$min,$sec)=UnixDate($date2,'%Y','%m','%d','%H','%M','%S');
}
$time = "$year-$mon-$mday $hour:$min:$sec";
- if (/\[(\w+?)\]\s+\(from (.+?)\)/){
+ if (/\[([\w\-]+?)\]\s+\(from (.+?)\)/){
+ $user = $1;
+ ($nas,$port,$caller) = (split /\s+/,$2)[1,3,5];
+ }
+ elsif (/\[([\w\-]+?)\/.+?\]\s+\(from (.+?)\)/){
$user = $1;
($nas,$port,$caller) = (split /\s+/,$2)[1,3,5];
}
$caller='' if (!defined($caller));
$user =~s/[^\w]//g;
$nas =~s/[^\w]//g;
- if ($nas !~ /\.$domain$/){
+ if ($nas ne 'localhost' && $nas !~ /\.$domain$/){
$nas .= '.$domain';
}
$port =~s/[^\d]//g;
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`;
+ print "$mysql -h$sql_server -u$sql_username $pass $sql_database <$tmpfile\n";
}
}
}