mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-28 03:33:25 +02:00
ids.cgi: Finish code to handle the removal of a provider from the list.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
This commit is contained in:
@@ -906,6 +906,9 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'save'}) {
|
|||||||
# Read-in provider settings file.
|
# Read-in provider settings file.
|
||||||
&General::readhasharray($IDS::providers_settings_file, \%used_providers);
|
&General::readhasharray($IDS::providers_settings_file, \%used_providers);
|
||||||
|
|
||||||
|
# Grab the provider name bevore deleting it from hash.
|
||||||
|
my $provider = $used_providers{$cgiparams{'ID'}}[0];
|
||||||
|
|
||||||
# Drop entry from the hash.
|
# Drop entry from the hash.
|
||||||
delete($used_providers{$cgiparams{'ID'}});
|
delete($used_providers{$cgiparams{'ID'}});
|
||||||
|
|
||||||
@@ -915,15 +918,40 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'save'}) {
|
|||||||
# Write the changed hash to the provide settings file.
|
# Write the changed hash to the provide settings file.
|
||||||
&General::writehasharray($IDS::providers_settings_file, \%used_providers);
|
&General::writehasharray($IDS::providers_settings_file, \%used_providers);
|
||||||
|
|
||||||
# XXX - The ruleset of the provider needs to be dropped.
|
# Drop the stored ruleset file.
|
||||||
# XXX - The remain rulest of suricata needs to be regenerated.
|
&IDS::drop_dl_rulesfile($provider);
|
||||||
# XXX - Suricata requires a reload or if the last provider has
|
|
||||||
# been removed it has to be stopped.
|
# Get the name of the provider rulessets include file.
|
||||||
|
my $provider_used_rulefile = &get_used_provider_rulesfile_file($provider);
|
||||||
|
|
||||||
|
# Drop the file, it is not longer needed.
|
||||||
|
unlink("$provider_used_rulefile");
|
||||||
|
|
||||||
|
# Regenerate ruleset.
|
||||||
|
&IDS::oinkmaster();
|
||||||
|
|
||||||
|
# Gather all enabled providers.
|
||||||
|
my @enabled_providers = &IDS::get_enabled_providers();
|
||||||
|
|
||||||
|
# Regenerate 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.
|
# Get amount of enabled providers.
|
||||||
# &IDS::call_suricatactrl("reload");
|
my $amount = @enabled_providers;
|
||||||
#}
|
|
||||||
|
# Check if at least one enabled provider remains.
|
||||||
|
if ($amount >= 1) {
|
||||||
|
# Call suricatactrl to perform a reload.
|
||||||
|
&IDS::call_suricatactrl("restart");
|
||||||
|
|
||||||
|
# Stop suricata if no enabled provider remains.
|
||||||
|
} else {
|
||||||
|
# Call suricatactrel to perform the stop.
|
||||||
|
&IDS::call_suricatactrl("stop");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Undefine providers flag.
|
# Undefine providers flag.
|
||||||
undef($cgiparams{'PROVIDERS'});
|
undef($cgiparams{'PROVIDERS'});
|
||||||
|
|||||||
Reference in New Issue
Block a user