]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
update-ids-ruleset: Add logging for various events.
authorStefan Schantl <stefan.schantl@ipfire.org>
Sat, 26 Mar 2022 10:22:08 +0000 (11:22 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Sat, 26 Mar 2022 10:22:08 +0000 (11:22 +0100)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
src/scripts/update-ids-ruleset

index 3c5cf583b0098bb3b70a1eb9e18e6547c052f5f1..267ccdb254b6602cfd5173ba29ae3cb0a5b4d698 100644 (file)
@@ -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("<INFO> 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("<INFO> 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("<INFO> Skipping $provider - The ruleset is up-to-date");
+
+               } elsif ($return eq "no url") {
+                       # Log error to the syslog.
+                       &_log_to_syslog("<ERROR> Could not determine a download URL for $provider.");
+
+               } else {
+                       # Log error to syslog.
+                       &_log_to_syslog("<ERROR> $return");
+               }
+       } else {
+               # Log successfull update.
+               &_log_to_syslog("<INFO> 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.