ids.cgi: Create oinkmaster related files at first call

With this commit, the CGI file will create the oinkmaster related
files during first run if they does not exist.

Fixes #11822.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
This commit is contained in:
Stefan Schantl
2018-08-24 07:39:04 +02:00
parent 308ba5e74c
commit 01ba4be48d

View File

@@ -53,8 +53,22 @@ my $idsusedrulefilesfile = "$IDS::settingsdir/suricata-used-rulefiles.yaml";
# File where the addresses of the homenet are stored.
my $idshomenetfile = "$IDS::settingsdir/suricata-homenet.yaml";
# File which contains the enabled sids.
my $enabled_sids_file = "$IDS::settingsdir/oinkmaster-enabled-sids.conf";
# File which contains the disabled sids.
my $disabled_sids_file = "$IDS::settingsdir/oinkmaster-disabled-sids.conf";
# File which contains wheater the rules should be changed.
my $modify_sids_file = "$IDS::settingsdir/oinkmaster-modify-sids.conf";
my $errormessage;
# Create oinkmaster related files if they does not exist yet.
unless (-f "$enabled_sids_file") { &IDS::create_empty_file($enabled_sids_file); }
unless (-f "$disabled_sids_file") { &IDS::create_empty_file($disabled_sids_file); }
unless (-f "$modify_sids_file") { &IDS::create_empty_file($modify_sids_file); }
&Header::showhttpheaders();
#Get GUI values
@@ -138,9 +152,6 @@ if(-f $idsusedrulefilesfile) {
# Save ruleset.
if ($cgiparams{'RULESET'} eq $Lang::tr{'update'}) {
my $enabled_sids_file = "$IDS::settingsdir/oinkmaster-enabled-sids.conf";
my $disabled_sids_file = "$IDS::settingsdir/oinkmaster-disabled-sids.conf";
# Arrays to store which rulefiles have been enabled and will be used.
my @enabled_rulefiles;
@@ -342,9 +353,6 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'update'}) {
# Generate file to store the home net.
&generate_home_net_file();
# File which contains wheater the rules should be changed.
my $modify_sids_file = "$IDS::settingsdir/oinkmaster-modify-sids.conf";
# Open modify sid's file for writing.
open(FILE, ">$modify_sids_file") or die "Could not write to $modify_sids_file. $!\n";