]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
ids.cgi: Always write config files for enabled/disabled rule files
authorStefan Schantl <stefan.schantl@ipfire.org>
Tue, 12 Dec 2017 19:16:26 +0000 (20:16 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Thu, 26 Jul 2018 09:45:02 +0000 (11:45 +0200)
If a single sid has been activated and then disabled without doing
any other ruleset modifications only one of the oinkmaster files
for enabled / disabled rules has been modified.

In this case it was possible, that the same sid, was part of the
file for enabled rules and part of the file for disabled rules at the
same time.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
html/cgi-bin/ids.cgi

index 8a6e51b1d4e20ca7707c677745de1072082890a0..dcf821888bbb1463447f9611be304a31f2610072 100644 (file)
@@ -182,42 +182,42 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'update'}) {
                }
        }
 
-       # Check if the enabled_sids array contains any sid's.
-       if (@enabled_sids) {
-               # Open enabled sid's file for writing.
-               open(FILE, ">$enabled_sids_file") or die "Could not write to $enabled_sids_file. $!\n";
+       # Open enabled sid's file for writing.
+       open(FILE, ">$enabled_sids_file") or die "Could not write to $enabled_sids_file. $!\n";
 
-               # Write header to file.
-               print FILE "#Autogenerated file. Any custom changes will be overwritten!\n";
+       # Write header to file.
+       print FILE "#Autogenerated file. Any custom changes will be overwritten!\n";
 
+       # Check if the enabled_sids array contains any sid's.
+       if (@enabled_sids) {
                # Loop through the array of enabled sids and write them to the file.
                foreach my $sid (@enabled_sids) {
-                       print FILE "enable_sid $sid\n";
+                       print FILE "enablesid $sid\n";
                }
-
-               # Close file after writing.
-               close(FILE);
        }
 
-       # Check if the enabled_sids array contains any sid's.
-       if (@disabled_sids) {
-                # Open disabled sid's file for writing.
-                open(FILE, ">$disabled_sids_file") or die "Could not write to $disabled_sids_file. $!\n";
+       # Close file after writing.
+       close(FILE);
 
-                # Write header to file.
-                print FILE "#Autogenerated file. Any custom changes will be overwritten!\n";
+       # Open disabled sid's file for writing.
+       open(FILE, ">$disabled_sids_file") or die "Could not write to $disabled_sids_file. $!\n";
 
-                # Loop through the array of disabled sids and write them to the file.
-                foreach my $sid (@disabled_sids) {
-                        print FILE "disable_sid $sid\n";
-                }
+       # Write header to file.
+       print FILE "#Autogenerated file. Any custom changes will be overwritten!\n";
 
-                # Close file after writing.
-                close(FILE);
-        }
+       # Check if the enabled_sids array contains any sid's.
+        if (@disabled_sids) {
+               # Loop through the array of disabled sids and write them to the file.
+               foreach my $sid (@disabled_sids) {
+                       print FILE "disablesid $sid\n";
+               }
+       }
+
+       # Close file after writing.
+       close(FILE);
 
        # Open file for used rulefiles.
-       open (FILE, ">$snortusedrulefilesfile") or die "Could not wirte to $snortusedrulefilesfile. $!\n";
+       open (FILE, ">$snortusedrulefilesfile") or die "Could not write to $snortusedrulefilesfile. $!\n";
 
        # Write header to file.
        print FILE "#Autogenerated file. Any custom changes will be overwritten!\n";