ids.cgi: Finish code to handle toggeling a provider enabled/disabled.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
This commit is contained in:
Stefan Schantl
2021-04-01 11:46:11 +02:00
parent ddaf8ae1a8
commit a2b4488ae5

View File

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