mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-28 03:33:25 +02:00
IDS: Introduce settingsdir variable
The $settingsdir variable is declared in the ids-functions.pl and used to to store the path where the various files which contains the settings for the IDS and oinkmaster is located. Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
This commit is contained in:
@@ -47,7 +47,7 @@ my %selected=();
|
||||
# Get netsettings.
|
||||
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
|
||||
|
||||
my $snortusedrulefilesfile = "${General::swroot}/snort/snort-used-rulefiles.conf";
|
||||
my $idsusedrulefilesfile = "$IDS::settingsdir/ids-used-rulefiles.conf";
|
||||
my $errormessage;
|
||||
|
||||
&Header::showhttpheaders();
|
||||
@@ -108,9 +108,9 @@ closedir(DIR);
|
||||
# Gather used rulefiles.
|
||||
#
|
||||
# Check if the file for activated rulefiles is not empty.
|
||||
if(-f $snortusedrulefilesfile) {
|
||||
if(-f $idsusedrulefilesfile) {
|
||||
# Open the file for used rulefile and read-in content.
|
||||
open(FILE, $snortusedrulefilesfile) or die "Could not open $snortusedrulefilesfile. $!\n";
|
||||
open(FILE, $idsusedrulefilesfile) or die "Could not open $idsusedrulefilesfile. $!\n";
|
||||
|
||||
# Read-in content.
|
||||
my @lines = <FILE>;
|
||||
@@ -141,8 +141,8 @@ if(-f $snortusedrulefilesfile) {
|
||||
|
||||
# Save ruleset.
|
||||
if ($cgiparams{'RULESET'} eq $Lang::tr{'update'}) {
|
||||
my $enabled_sids_file = "${General::swroot}/snort/oinkmaster-enabled-sids.conf";
|
||||
my $disabled_sids_file = "${General::swroot}/snort/oinkmaster-disabled-sids.conf";
|
||||
my $enabled_sids_file = "$IDS::settingsdir/oinkmaster-enabled-sids.conf";
|
||||
my $disabled_sids_file = "$IDS::settingsdir/oinkmaster-disabled-sids.conf";
|
||||
|
||||
# Arrays to store sid which should be added to the corresponding files.
|
||||
my @enabled_sids;
|
||||
@@ -232,7 +232,7 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'update'}) {
|
||||
close(FILE);
|
||||
|
||||
# Open file for used rulefiles.
|
||||
open (FILE, ">$snortusedrulefilesfile") or die "Could not write to $snortusedrulefilesfile. $!\n";
|
||||
open (FILE, ">$idsusedrulefilesfile") or die "Could not write to $idsusedrulefilesfile. $!\n";
|
||||
|
||||
# Write header to file.
|
||||
print FILE "#Autogenerated file. Any custom changes will be overwritten!\n";
|
||||
@@ -307,7 +307,7 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'update'}) {
|
||||
# Go on if there are no error messages.
|
||||
if (!$errormessage) {
|
||||
# Store settings into settings file.
|
||||
&General::writehash("${General::swroot}/snort/settings", \%cgiparams);
|
||||
&General::writehash("$IDS::settingsdir/settings", \%cgiparams);
|
||||
|
||||
# Call snortctrl to restart snort
|
||||
system('/usr/local/bin/snortctrl restart >/dev/null');
|
||||
@@ -315,7 +315,7 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'update'}) {
|
||||
}
|
||||
|
||||
# Read-in snortsettings
|
||||
&General::readhash("${General::swroot}/snort/settings", \%snortsettings);
|
||||
&General::readhash("$IDS::settingsdir/settings", \%snortsettings);
|
||||
|
||||
$checked{'ENABLE_SNORT'}{'off'} = '';
|
||||
$checked{'ENABLE_SNORT'}{'on'} = '';
|
||||
|
||||
Reference in New Issue
Block a user