From db57c39a7b4febb4e3fb6cf03092b56cf52f8c9f Mon Sep 17 00:00:00 2001 From: kkalev Date: Mon, 30 Dec 2002 10:15:15 +0000 Subject: [PATCH] Add sql_connect_timeout and sql_extra_servers configuration directives to be used by the log_badlogins script --- Changelog | 1 + bin/log_badlogins | 10 +++++++++- conf/admin.conf | 8 ++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 4969a6c..ecc8dcc 100644 --- a/Changelog +++ b/Changelog @@ -20,6 +20,7 @@ Ver 1.62: credentials (that way there can be more than one administrator usernames, each with different privileges on the sql database). * Add more error messages when interacting with the SQL database +* Add sql_connect_timeout and sql_extra_servers configuration directives to be used by the log_badlogins script Ver 1.61: * Add a string encoder for greek * If general_decode_normal_attributes is set then encode attributes in lib/ldap/change_info. In the near future diff --git a/bin/log_badlogins b/bin/log_badlogins index bb6c2a9..88632ce 100755 --- a/bin/log_badlogins +++ b/bin/log_badlogins @@ -41,12 +41,17 @@ while(){ $realm_strip = $val if ($key eq 'general_strip_realms'); $realm_del = $val if ($key eq 'general_realm_delimiter'); $realm_for = $val if ($key eq 'general_realm_format'); + $sql_timeout = $val if ($key eq 'sql_connect_timeout'); + $sql_extra = $val if ($key eq 'sql_extra_servers'); } close CONF; $realm_del = '@' if ($realm_del eq ''); $realm_for = 'suffix' if ($realm_for eq ''); $pass = ($sql_password ne '') ? "-p$sql_password" : ''; +$opt = "-O connect_timeout=$sql_timeout" if ($sql_timeout); +@extras = (split /\s+/,$sql_extra) if ($sql_extra ne ''); + open LOG, "<$file" or die "Could not open file $file\n"; @@ -117,7 +122,10 @@ for(;;){ 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`; + `$mysql -h$sql_server $opt -u$sql_username $pass $sql_database <$tmpfile`; + foreach $extra (@extras){ + `$mysql -h$extra $opt -u$sql_username $pass $sql_database <$tmpfile`; + } } } } diff --git a/conf/admin.conf b/conf/admin.conf index 79c4d52..12f53c6 100644 --- a/conf/admin.conf +++ b/conf/admin.conf @@ -200,6 +200,14 @@ sql_full_date_format: Y-m-d H:i:s # don't return too many results # sql_row_limit: 40 +# +# These options are used by the log_badlogins script +# +# Set the sql connect timeout (secs) +sql_connect_timeout: 3 +# Give a space separated list of extra mysql servers to connect to when +# logging bad logins +#sql_extra_servers: sql2.company.com sql3.company.com counter_default_daily: 14400 counter_default_weekly: 72000 -- 2.39.5