]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
IDS: Move read_enabled_disabled_sids_file() function to ids-functions.pl.
authorStefan Schantl <stefan.schantl@ipfire.org>
Sun, 4 Apr 2021 08:15:27 +0000 (10:15 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Sun, 19 Dec 2021 12:23:44 +0000 (13:23 +0100)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
config/cfgroot/ids-functions.pl
html/cgi-bin/ids.cgi

index c231e0d444772216cf138939effd2d2a95c46758..e305be15f7df2da041fb6121bc2fa3af21888626 100644 (file)
@@ -955,6 +955,57 @@ sub alter_oinkmaster_provider_includes_file ($$) {
        close(FILE);
 }
 
+#
+## Function to read-in the given enabled or disables sids file.
+#
+sub read_enabled_disabled_sids_file($) {
+       my ($file) = @_;
+
+       # Temporary hash to store the sids and their state. It will be
+       # returned at the end of this function.
+       my %temphash;
+
+       # Open the given filename.
+       open(FILE, "$file") or die "Could not open $file. $!\n";
+
+       # Loop through the file.
+       while(<FILE>) {
+               # Remove newlines.
+               chomp $_;
+
+               # Skip blank lines.
+               next if ($_ =~ /^\s*$/);
+
+               # Skip coments.
+               next if ($_ =~ /^\#/);
+
+               # Splitt line into sid and state part.
+               my ($state, $sid) = split(" ", $_);
+
+               # Skip line if the sid is not numeric.
+               next unless ($sid =~ /\d+/ );
+
+               # Check if the sid was enabled.
+               if ($state eq "enablesid") {
+                       # Add the sid and its state as enabled to the temporary hash.
+                       $temphash{$sid} = "enabled";
+               # Check if the sid was disabled.
+               } elsif ($state eq "disablesid") {
+                       # Add the sid and its state as disabled to the temporary hash.
+                       $temphash{$sid} = "disabled";
+               # Invalid state - skip the current sid and state.
+               } else {
+                       next;
+               }
+       }
+
+       # Close filehandle.
+       close(FILE);
+
+       # Return the hash.
+       return %temphash;
+}
+
 #
 ## Function to check if the IDS is running.
 #
index 47e9ac778db7db9f4dc9d96abd4325160465e37d..8ee16930a3bceedc56a98187311207d111d24b57 100644 (file)
@@ -358,7 +358,7 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'ids apply'}) {
                # Check if a modified sids file for this provider exists.
                if (-f $providers_modified_sids_file) {
                        # Read-in the file for enabled/disabled sids.
-                       %enabled_disabled_sids = &read_enabled_disabled_sids_file($providers_modified_sids_file);
+                       %enabled_disabled_sids = &IDS::read_enabled_disabled_sids_file($providers_modified_sids_file);
                }
 
                # Loop through the hash of idsrules.
@@ -1990,57 +1990,6 @@ sub get_memory_usage($) {
        return;
 }
 
-#
-## Function to read-in the given enabled or disables sids file.
-#
-sub read_enabled_disabled_sids_file($) {
-       my ($file) = @_;
-
-       # Temporary hash to store the sids and their state. It will be
-       # returned at the end of this function.
-       my %temphash;
-
-       # Open the given filename.
-       open(FILE, "$file") or die "Could not open $file. $!\n";
-
-       # Loop through the file.
-       while(<FILE>) {
-               # Remove newlines.
-               chomp $_;
-
-               # Skip blank lines.
-               next if ($_ =~ /^\s*$/);
-
-               # Skip coments.
-               next if ($_ =~ /^\#/);
-
-               # Splitt line into sid and state part.
-               my ($state, $sid) = split(" ", $_);
-
-               # Skip line if the sid is not numeric.
-               next unless ($sid =~ /\d+/ );
-
-               # Check if the sid was enabled.
-               if ($state eq "enablesid") {
-                       # Add the sid and its state as enabled to the temporary hash.
-                       $temphash{$sid} = "enabled";
-               # Check if the sid was disabled.
-               } elsif ($state eq "disablesid") {
-                       # Add the sid and its state as disabled to the temporary hash.
-                       $temphash{$sid} = "disabled";
-               # Invalid state - skip the current sid and state.
-               } else {
-                       next;
-               }
-       }
-
-       # Close filehandle.
-       close(FILE);
-
-       # Return the hash.
-       return %temphash;
-}
-
 #
 ## Function to get the provider name from the language file or providers file for a given handle.
 #