# Load perl module to talk to the kernel syslog.
use Sys::Syslog qw(:DEFAULT setlogsock);
+# Load module to get file stats.
+use File::stat;
+
require '/var/ipfire/general-functions.pl';
require "${General::swroot}/ipblocklist-functions.pl";
require "${General::swroot}/lang.pl";
# They need to be reloaded.
my @updated_blocklists = ();
-# Gather the details, when a list got modified last time.
-my %modified = ();
-
-# Read-in data if the file exists.
-&General::readhash($IPblocklist::modified_file, \%modified ) if (-e $IPblocklist::modified_file);
-
# Loop through the array of blocklists.
foreach my $blocklist (@blocklists) {
# Skip if the blocklist is not enabled.
next if($settings{$blocklist} ne "on");
+ # Get name and full path of the cached blocklist file.
+ my $cached_file = &IPblocklist::get_cached_blocklist_file($blocklist);
+
+ # Call stat on the cached blocklist file if it is present.
+ my $stat = stat($cached_file) if (-f $cached_file);
+
+ # Omit the time the file last time has been modified.
+ my $last_download_time = $stat->mtime;
+
# Get current time.
my $time = time();
- # Get time, when the blocklist has been downloaded last.
- my $last_download_time = $modified{$blocklist};
-
# Get the holdoff rate in seconds for the current processed blocklist.
my $rate_time = &IPblocklist::get_holdoff_rate($blocklist);
my $holdoff_time = $last_download_time + $rate_time;
# Check if enough time has passed since the last download of the list.
- if ($time <= $holdoff_time) {
+ if ($time le $holdoff_time) {
# To frequent updates, log to syslog.
&_log_to_syslog("<INFO> Skipping $blocklist blocklist - Too frequent update attempts!");
&_log_to_syslog("<ERROR> Could not update $blocklist blocklist - Unexpected error\!");
}
} else {
- # Get the filename of the blocklist.
- my $cached_file = &IPblocklist::get_cached_blocklist_file($blocklist);
-
# Set the correct ownership.
&IPblocklist::set_ownership($cached_file);