]> git.entuzijast.net Git - freeradius-dialup-admin.git/commitdiff
* Make all scripts use the mysql binary instead of DBI and make the sql password...
authorkkalev <kkalev>
Sat, 19 Jul 2003 16:29:50 +0000 (16:29 +0000)
committerkkalev <kkalev>
Sat, 19 Jul 2003 16:29:50 +0000 (16:29 +0000)
* Make log_badlogins work with usernames containing spaces

Changelog
bin/clean_radacct
bin/log_badlogins
bin/monthly_tot_stats
bin/tot_stats
bin/truncate_radacct

index a0a1e89fe774ceb3378e589f6a393968e57ea74a..a16efebf2ed9bd20a354b28f1fd3208fa035b570 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -33,6 +33,8 @@ Ver 1.63:
 * Add Service-Type in user_edit.attrs
 * In user_finger page if $user is NULL then set it to &nbsp;
 * Add 3 more help pages from Stadler Karel <Karel.Stadler@psi.ch> for Service-Type,Framed-Protocol and Filter-ID
+* Make all scripts use the mysql binary instead of DBI  and make the sql password even if it is empty
+* Make log_badlogins work with usernames containing spaces
 Ver 1.62:
 * Remove one sql query from user_admin which was not needed.
 * Instead of a query like "LIKE 'YYYY-MM-DD%'" use "AcctStopTime >= 'YYYY-MM-DD 00:00:00 AND AcctStopTime
index 29fbd1afe3f36562575ec317ba2c6a3cf56e22a0..e89cf112c18c8d2db42f010f7d8b15ef8df2aa13 100755 (executable)
@@ -3,10 +3,10 @@
 # Clean stale open sessions from the radacct table.
 # we only clean up sessions which are older than $back_days
 #
-use DBI;
 use POSIX;
 
 $conf=shift||'/usr/local/dialup_admin/conf/admin.conf';
+$mysql='/usr/local/mysql/bin/mysql';
 $back_days = 35;
 
 open CONF, "<$conf"
@@ -22,10 +22,16 @@ while(<CONF>){
 }
 close CONF;
 
+$sql_password = ($sql_password == '') ? '' : "-p $sql_password";
+
 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
 $date = POSIX::strftime("%Y-%m-%d %T",$sec,$min,$hour,($mday - $back_days),$mon,$year,$wday,$yday,$isdst);
 print "$date\n";
 
-$dbh = DBI->connect("DBI:mysql:$sql_database:$sql_server","$sql_username","$sql_password");
-$dbh->do("DELETE FROM $sql_accounting_table WHERE AcctStopTime = '0' AND AcctStartTime < '$date';");
-$dbh->disconnect();
+$query = "DELETE FROM $sql_accounting_table WHERE AcctStopTime = '0' AND AcctStartTime < '$date';";
+print "$query\n";
+open TMP, ">/tmp/clean_radacct.query"
+        or die "Could not open tmp file\n";
+print TMP $query;
+close TMP;
+`$mysql -h $sql_server -u $sql_username $sql_password $sql_database </tmp/clean_radacct.query`;
index 092c56af8ecce9fc99cfc5d3f09a92a9a9c46ef0..d733acb5624355fcc15fe7c318f9c782a5ee6a64 100755 (executable)
@@ -96,16 +96,16 @@ for(;;){
                                        ($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]+?)\]\s+\(from (.+?)\)/){
                                        $user = $1;
                                        ($nas,$port,$caller) = (split /\s+/,$2)[1,3,5];
                                }
-                               elsif (/\[([\w\-\.\!\@]+?)\/.+?\]\s+\(from (.+?)\)/){
+                               elsif (/\[([\w\-\.\!\@\s]+?)\/.+?\]\s+\(from (.+?)\)/){
                                        $user = $1;
                                        ($nas,$port,$caller) = (split /\s+/,$2)[1,3,5];
                                }
                                $caller='' if (!defined($caller));
-                               $user =~s/[^\w\-\.\d\!\@]//g;
+                               $user =~s/[^\w\-\.\d\!\@\s]//g;
                                $nas =~s/[^\w\.]//g;
                                if ($nas ne 'localhost' && $nas !~ /\.$domain$/){
                                        $nas .= ".$domain";
index 22f2ddcba64a09de97762bb1978586017c980d64..4eeafeaf541cacd64ca4a841c6bd0ed684ff2a88 100755 (executable)
@@ -22,6 +22,8 @@ while(<CONF>){
 }
 close CONF;
 
+$sql_password = ($sql_password == '') ? '' : "-p $sql_password";
+
 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
 if ($mday == 1){
        $mon--;
@@ -44,4 +46,4 @@ open TMP, ">/tmp/tot_stats.query"
 print TMP $query1;
 print TMP $query2;
 close TMP;
-`$mysql -h $sql_server -u $sql_username -p$sql_password $sql_database </tmp/tot_stats.query`;
+`$mysql -h $sql_server -u $sql_username $sql_password $sql_database </tmp/tot_stats.query`;
index 2d60b46645f6e02a8f5233c8e062647e7393f3de..46a1de0c2f884b11a160b0a76ee5282ad9a913bc 100755 (executable)
@@ -22,6 +22,8 @@ while(<CONF>){
 }
 close CONF;
 
+$sql_password = ($sql_password == '') ? '' : "-p $sql_password";
+
 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
 $date_start = POSIX::strftime("%Y-%m-%d %T",0,0,0,($mday - 1),$mon,$year,$wday,$yday,$isdst);
 $date_small_start = POSIX::strftime("%Y-%m-%d",0,0,0,($mday - 1),$mon,$year,$wday,$yday,$isdst);
@@ -39,4 +41,4 @@ open TMP, ">/tmp/tot_stats.query"
        or die "Could not open tmp file\n";
 print TMP $query;
 close TMP;
-`$mysql -h $sql_server -u $sql_username -p$sql_password $sql_database </tmp/tot_stats.query`;
+`$mysql -h $sql_server -u $sql_username $sql_password $sql_database </tmp/tot_stats.query`;
index 97210714159e5144463848a8281ecec4ec278036..b6b52c364205f439ecce4d505a347f6d822200d9 100755 (executable)
@@ -3,10 +3,10 @@
 # Delete sessions from the radacct table which are older than
 # $back_days
 #
-use DBI;
 use POSIX;
 
 $conf=shift||'/usr/local/dialup_admin/conf/admin.conf';
+$mysql='/usr/local/mysql/bin/mysql';
 $back_days = 90;
 
 open CONF, "<$conf"
@@ -22,10 +22,18 @@ while(<CONF>){
 }
 close CONF;
 
+$sql_password = ($sql_password == '') ? '' : "-p $sql_password";
+
 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
 $date = POSIX::strftime("%Y-%m-%d %T",$sec,$min,$hour,($mday - $back_days),$mon,$year,$wday,$yday,$isdst);
 print "$date\n";
 
-$dbh = DBI->connect("DBI:mysql:$sql_database:$sql_server","$sql_username","$sql_password");
-$dbh->do("LOCK TABLES $sql_accounting_table WRITE;DELETE FROM $sql_accounting_table WHERE AcctStopTime < '$date';UNLOCK TABLES;");
-$dbh->disconnect();
+$query = "LOCK TABLES $sql_accounting_table WRITE;";
+$query .= "DELETE FROM $sql_accounting_table WHERE AcctStopTime < '$date';";
+$query .= "UNLOCK TABLES;";
+print "$query\n";
+open TMP, ">/tmp/truncate_radacct.query"
+        or die "Could not open tmp file\n";
+print TMP $query;
+close TMP;
+`$mysql -h $sql_server -u $sql_username $sql_password $sql_database </tmp/truncate_radacct.query`;