From c9c3eadbbffeee8a4f46365e917f619939dee9f1 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Sat, 26 Mar 2022 11:22:08 +0100 Subject: [PATCH] update-ids-ruleset: Add logging for various events. Signed-off-by: Stefan Schantl --- src/scripts/update-ids-ruleset | 46 ++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 16 deletions(-) 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. -- 2.39.5