From 8bfbce68e503b2ddcdcc9619307d168b1c332df3 Mon Sep 17 00:00:00 2001 From: VVelox Date: Thu, 23 Feb 2017 09:54:38 -0600 Subject: [PATCH] if cache older than 360 seconds, don't use it --- snmp/fail2ban | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/snmp/fail2ban b/snmp/fail2ban index f1b7858..18934e2 100644 --- a/snmp/fail2ban +++ b/snmp/fail2ban @@ -45,7 +45,12 @@ getopts('u', \%opts); my $noWrite=0; if ( ! defined( $opts{u} ) ){ - if ( -f $cache ){ + my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, + $atime,$mtime,$ctime,$blksize,$blocks) = stat($cache); + my $age=time-$mtime; + + + if (( -f $cache )&&( $age < 360 )){ my $old=''; open(my $readfh, "<", $cache) or die "Can't open '".$cache."'"; # if this is over 2048, something is most likely wrong @@ -55,7 +60,6 @@ if ( ! defined( $opts{u} ) ){ }else{ $opts{u}=1; $noWrite=1; - } }