]> 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>
Sun, 19 Dec 2021 12:23:42 +0000 (13:23 +0100)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
html/cgi-bin/ids.cgi

index 908ad9c287a894213bd6901a66389c6881652220..e927fb617bebef3d69db5c4f9ceb090593f1278c 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'});