From: Stefan Schantl Date: Sat, 26 Mar 2022 10:22:08 +0000 (+0100) Subject: update-ids-ruleset: Add logging for various events. X-Git-Tag: v2.27-core170~195^2~64 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c9c3eadbbffeee8a4f46365e917f619939dee9f1;p=ipfire-2.x.git update-ids-ruleset: Add logging for various events. Signed-off-by: Stefan Schantl --- diff --git a/src/scripts/update-ids-ruleset b/src/scripts/update-ids-ruleset index 3c5cf583b0..267ccdb254 100644 --- a/src/scripts/update-ids-ruleset +++ b/src/scripts/update-ids-ruleset @@ -56,7 +56,7 @@ openlog('oinkmaster', 'cons,pid', 'user'); # ruleset. if (-f "$IDS::ids_page_lock_file") { # Store notice to the syslog. - &IDS::_log_to_syslog("Another process currently is altering the IDS ruleset."); + &_log_to_syslog(" Autoupdate skipped - Another process was altering the IDS ruleset."); # Exit. exit 0; @@ -101,23 +101,37 @@ foreach my $id (keys %providers) { # Skip the provider if autoupdate is not enabled. next unless($autoupdate_status eq "enabled"); - # Call the download function and gather the new ruleset for the current processed provider. - if(&IDS::downloadruleset($provider)) { - # Store error message for displaying in the WUI. - &IDS::_store_error_message("$provider: $Lang::tr{'could not download latest updates'}"); - - # Unlock the IDS page. - &IDS::unlock_ids_page(); + # Log notice about update. + &_log_to_syslog(" Performing update for $provider."); - # Exit. - exit 0; + # Call the download function and gather the new ruleset for the current processed provider. + my $return = &IDS::downloadruleset($provider); + + # Check if we got a return code. + if ($return) { + # Handle different return codes. + if ($return eq "not_modified") { + # Log notice to syslog. + &_log_to_syslog(" Skipping $provider - The ruleset is up-to-date"); + + } elsif ($return eq "no url") { + # Log error to the syslog. + &_log_to_syslog(" Could not determine a download URL for $provider."); + + } else { + # Log error to syslog. + &_log_to_syslog(" $return"); + } + } else { + # Log successfull update. + &_log_to_syslog(" Successfully updated ruleset for $provider."); + + # Get path and name of the stored rules file or archive. + my $stored_file = &IDS::_get_dl_rulesfile($provider); + + # Set correct ownership for the downloaded tarball. + &IDS::set_ownership("$stored_file"); } - - # Get path and name of the stored rules file or archive. - my $stored_file = &IDS::_get_dl_rulesfile($provider); - - # Set correct ownership for the downloaded tarball. - &IDS::set_ownership("$stored_file"); } # Call oinkmaster to alter the ruleset.