ids.cgi: Only write oinkmaster-modify-sids.conf if neccessary.

Only write to the file if the runmode of the IDS has been changed.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
This commit is contained in:
Stefan Schantl
2018-09-26 13:02:28 +02:00
parent 5508f18c01
commit dae534f2ca

View File

@@ -517,23 +517,23 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'update'}) {
# Generate file to store the home net.
&generate_home_net_file();
# Open modify sid's file for writing.
open(FILE, ">$modify_sids_file") or die "Could not write to $modify_sids_file. $!\n";
# Write file header.
print FILE "#Autogenerated file. Any custom changes will be overwritten!\n";
# Check if the configured runmode is IPS.
if ($cgiparams{'RUN_MODE'} eq 'IPS') {
# Tell oinkmaster to switch all rules from alert to drop.
print FILE "modifysid \* \"alert\" \| \"drop\"\n";
}
# Close file handle.
close(FILE);
# Check if the runmode has been changed.
if($cgiparams{'RUN_MODE'} ne $oldidssettings{'RUN_MODE'}) {
# Open modify sid's file for writing.
open(FILE, ">$modify_sids_file") or die "Could not write to $modify_sids_file. $!\n";
# Write file header.
print FILE "#Autogenerated file. Any custom changes will be overwritten!\n";
# Check if the configured runmode is IPS.
if ($cgiparams{'RUN_MODE'} eq 'IPS') {
# Tell oinkmaster to switch all rules from alert to drop.
print FILE "modifysid \* \"alert\" \| \"drop\"\n";
}
# Close file handle.
close(FILE);
# Check if a ruleset exists.
if (%idsrules) {
# Lock the webpage and print message.