2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2021 IPFire Development Team <info@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 require '/var/ipfire/general-functions.pl';
25 require '/var/ipfire/ids-functions.pl';
27 # Exit if there is no main oinkmaster config file anymore.
28 exit 0 unless (-f
"$IDS::settingsdir/oinkmaster.conf");
30 # Get all supported providers.
31 my @providers = &IDS
::get_ruleset_providers
();
33 # Loop through the array of providers.
34 foreach my $provider (@providers) {
35 my %modifications = ();
37 # Generate old filename which hold the ruleset modifications.
38 my $old_modifications_file = "$IDS::settingsdir/oinkmaster\-$provider\-modified-sids.conf";
40 # Skip provider if there is no modifications file.
41 next unless (-f
$old_modifications_file);
43 # Open modifications file.
44 open(FILE
, "$old_modifications_file");
46 # Read-in file content.
52 # Loop through the file content.
53 foreach my $line (@file) {
56 # Split line and assign to an temporary array.
57 my @tmp = split(/ /, $line);
59 # Assign nice human-readable variables.
63 # Process stored rule action and assign to the modifications hash.
64 if ($action eq "enablesid") {
65 $modifications{$sid} = "enabled";
67 } elsif ($action eq "disablesid") {
68 $modifications{$sid} = "disabled";
72 # Get new filename which will hold the ruleset modifications for this provider.
73 my $new_modifications_file = &IDS
::get_provider_ruleset_modifications_file
($provider);
75 # Write new modifications file.
76 &General
::writehash
("$new_modifications_file", \
%modifications);
78 # Set correct ownership for the new modifications file.
79 &IDS
::set_ownership
("$new_modifications_file");