]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
ids.cgi: Finish code to handle toggeling a provider enabled/disabled.
authorStefan Schantl <stefan.schantl@ipfire.org>
Thu, 1 Apr 2021 09:46:11 +0000 (11:46 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Wed, 8 Sep 2021 17:37:24 +0000 (19:37 +0200)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
html/cgi-bin/ids.cgi

index fc3234474cf76d06edd73a438c59f56e56a7f2c6..03d4a19470e016581ff856a211eb304b6a599556 100644 (file)
@@ -871,14 +871,28 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'save'}) {
                # Write the changed hash to the providers settings file.
                &General::writehasharray($IDS::providers_settings_file, \%used_providers);
 
-               # XXX - The ruleset needs to be regenerated
-               # XXX - Suricata requires a reload or if the last provider
-               #       has been disabled suricata needs to be stopped.
+               # Get all enabled providers.
+               my @enabled_providers = &IDS::get_enabled_providers();
+
+               # Write the main providers include file.
+               &IDS::write_main_used_rulefiles_file(@enabled_providers);
+
                # Check if the IDS is running.
-               #if(&IDS::ids_is_running()) {
-               #       # Call suricatactrl to perform a reload.
-               #       &IDS::call_suricatactrl("reload");
-               #}
+               if(&IDS::ids_is_running()) {
+                       # Gather the amount of enabled providers (elements in the array).
+                       my $amount = @enabled_providers;
+
+                       # Check if there are still enabled ruleset providers.
+                       if ($amount >= 1) {
+                               # Call suricatactrl to perform a restart.
+                               &IDS::call_suricatactrl("restart");
+
+                       # No active ruleset provider, suricata has to be stopped.
+                       } else {
+                               # Stop suricata.
+                               &IDS::call_suricatactrl("stop");
+                       }
+               }
 
                # Undefine providers flag.
                undef($cgiparams{'PROVIDERS'});