From 8c158ec422076444db488bc7ab92c24a212766fa Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 19 Nov 2013 11:48:21 +0100 Subject: [PATCH] Create the DB entry in one transaction to reduce the amount of logs for each ban --- root/sbin/e-smith/smeserver-fail2ban | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/root/sbin/e-smith/smeserver-fail2ban b/root/sbin/e-smith/smeserver-fail2ban index 46eaac9..90b2403 100644 --- a/root/sbin/e-smith/smeserver-fail2ban +++ b/root/sbin/e-smith/smeserver-fail2ban @@ -114,16 +114,16 @@ if ($opts{unban}){ } else{ my $id = generate_uniq_id(); - $f2bdb->new_record($id, {type => 'ban'}); - $f2bdb->set_prop($id, 'Host', $opts{host}); - $f2bdb->set_prop($id, 'Protocol', $opts{proto}) + my %props; + $props{'type'} = 'ban'; + $props{'Host'} = $opts{host}; + $props{'Protocol'} = $opts{proto} if ($opts{proto}); - $f2bdb->set_prop($id, 'Port', $opts{port}) - if ($opts{port}); - # Set the current timestamp - $f2bdb->set_prop($id, 'BanTimestamp', time()); - # Set the timestamp of the unban - $f2bdb->set_prop($id, 'UnbanTimestamp', time()+$opts{bantime}); + $props{'Port'} = $opts{proto} + if ($opts{proto}); + $props{'BanTimestamp'} = time(); + $props{'UnbanTimestamp'} = time()+$opts{bantime}; + $f2bdb->new_record($id, \%props); } die "An error occured while updating the firewall rules"