diff --git a/src/warden-server/lib/Warden.pm b/src/warden-server/lib/Warden.pm index a3e0fe5fd67f33db828b865442165936ab8fcaf3..31abf07a2cc991c6d330b5add64ca95158c46291 100755 --- a/src/warden-server/lib/Warden.pm +++ b/src/warden-server/lib/Warden.pm @@ -19,7 +19,6 @@ use Net::CIDR::Lite; use DateTime; use MIME::Base64; use Crypt::X509; -use List::Util 'first'; our $VERSION = "2.1"; @@ -222,9 +221,7 @@ sub saveNewEvent if(defined %client) { # check validity of event attributes - TYPE - my $valid_types_ref = $VALID_STRINGS{'type'}; - my @valid_types = @$valid_types_ref; - my $match = first { /$type/ } @valid_types; + my $match = grep /$type/, @{$VALID_STRINGS{'type'}}; if ($match) { $sth=$DBH->prepare("INSERT INTO events VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"); if (!defined $sth) { die("Cannot do insert statement in $function_name: $DBI::errstr\n") } @@ -263,27 +260,27 @@ sub getNewEvents if(defined %client) { if ($client{'receive_own'} eq 't') { # check if client want your own events or not if ($requested_type eq '_any_') { # check if client want each or only one type of messages - $sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND valid = 't' ORDER BY id ASC limit $MAX_EVENT_LIMIT;"); + $sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND valid = 't' ORDER BY id ASC LIMIT ?;"); if (!defined $sth) {die("Cannot prepare ROE-ANY statement in $function_name: $DBI::errstr\n")} - $sth->execute($last_id); + $sth->execute($last_id, $MAX_EVENT_LIMIT); } else { - $sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND type = ? AND valid = 't' ORDER BY id ASC limit $MAX_EVENT_LIMIT;"); + $sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND type = ? AND valid = 't' ORDER BY id ASC LIMIT ?;"); if (!defined $sth) {die("Cannot prepare ROE statement in $function_name: $DBI::errstr\n")} - $sth->execute($last_id, $requested_type); + $sth->execute($last_id, $requested_type, $MAX_EVENT_LIMIT); } } else { if ($requested_type eq '_any_') { - $sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND valid = 't' AND hostname NOT LIKE ? ORDER BY id ASC limit $MAX_EVENT_LIMIT;"); + $sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND valid = 't' AND hostname NOT LIKE ? ORDER BY id ASC LIMIT ?;"); if (!defined $sth) {die("Cannot prepare ANY statement in $function_name: $DBI::errstr\n")} my ($domain) = $cn =~ /([^\.]+\.[^\.]+)$/; $domain = '\%' . $domain; - $sth->execute($last_id, $domain); + $sth->execute($last_id, $domain, $MAX_EVENT_LIMIT); } else { - $sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND type = ? AND valid = 't' AND hostname NOT LIKE ? ORDER BY id ASC limit $MAX_EVENT_LIMIT;"); + $sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND type = ? AND valid = 't' AND hostname NOT LIKE ? ORDER BY id ASC LIMIT ?;"); if (!defined $sth) {die("Cannot prepare statement in $function_name: $DBI::errstr\n")} my ($domain) = $cn =~ /([^\.]+\.[^\.]+)$/; $domain = '\%' . $domain; - $sth->execute($last_id, $requested_type, $domain); + $sth->execute($last_id, $requested_type, $domain, $MAX_EVENT_LIMIT); } } diff --git a/src/warden-server/sh/install.sh b/src/warden-server/sh/install.sh index 72fb2282a37737fa44c1916fa602e177272a2f1b..82e15ddfb5656b4f207c22c7e98620a329e649a4 100755 --- a/src/warden-server/sh/install.sh +++ b/src/warden-server/sh/install.sh @@ -288,7 +288,7 @@ create_symlinks() #------------------------------------------------------------------------------- # list of used Perl modules -modules=(SOAP::Lite SOAP::Transport::HTTP DBI DBD::mysql Format::Human::Bytes Sys::Syslog File::Basename Net::CIDR::Lite DateTime Getopt::Std Switch IO::Socket::SSL MIME::Base64 Crypt::X509 List::Util) +modules=(SOAP::Lite SOAP::Transport::HTTP DBI DBD::mysql Format::Human::Bytes Sys::Syslog File::Basename Net::CIDR::Lite DateTime Getopt::Std Switch IO::Socket::SSL MIME::Base64 Crypt::X509) # read input while getopts "d:k:c:a:Vh" options; do