From 303caee845273ee89dcda1539f6c33b558ebea07 Mon Sep 17 00:00:00 2001 From: kkalev Date: Sat, 19 Jul 2003 16:29:50 +0000 Subject: [PATCH] * 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 --- Changelog | 2 ++ bin/clean_radacct | 14 ++++++++++---- bin/log_badlogins | 6 +++--- bin/monthly_tot_stats | 4 +++- bin/tot_stats | 4 +++- bin/truncate_radacct | 16 ++++++++++++---- 6 files changed, 33 insertions(+), 13 deletions(-) diff --git a/Changelog b/Changelog index a0a1e89..a16efeb 100644 --- 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   * Add 3 more help pages from Stadler Karel 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 diff --git a/bin/clean_radacct b/bin/clean_radacct index 29fbd1a..e89cf11 100755 --- a/bin/clean_radacct +++ b/bin/clean_radacct @@ -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(){ } 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 ){ } 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 ){ } 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 ){ } 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