ids-functions.pl: Introduce get_enabled_providers() function.

This function simply returns an array with all enabled ruleset
providers.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
This commit is contained in:
Stefan Schantl
2021-03-31 12:16:24 +02:00
parent dae33250b2
commit 5e20d6cb28

View File

@@ -163,6 +163,36 @@ sub get_ruleset_providers() {
return sort(@providers);
}
#
## Function to get a list of all enabled ruleset providers.
##
## They will be returned as an array.
#
sub get_enabled_providers () {
my %used_providers = ();
# Array to store the enabled providers.
my @enabled_providers = ();
# Read-in the providers config file.
&General::readhasharray("$providers_settings_file", \%used_providers);
# Loop through the hash of used_providers.
foreach my $id (keys %used_providers) {
# Skip disabled providers.
next unless ($used_providers{$id}[3] eq "enabled");
# Grab the provider handle.
my $provider = "$used_providers{$id}[0]";
# Add the provider to the array of enabled providers.
push(@enabled_providers, $provider);
}
# Return the array.
return @enabled_providers;
}
#
## Function for checking if at least 300MB of free disk space are available
## on the "/var" partition.