From: Stefan Schantl Date: Wed, 30 Jan 2019 08:57:49 +0000 (+0100) Subject: ids.cgi: Also download the ruleset when saving the ruleset settings X-Git-Tag: v2.23-core131~117^2~88 X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=commitdiff_plain;h=5fd2e9d64ac8363ac56bf0431ec3607e099b3f46 ids.cgi: Also download the ruleset when saving the ruleset settings Signed-off-by: Stefan Schantl --- diff --git a/html/cgi-bin/ids.cgi b/html/cgi-bin/ids.cgi index 1086ae9686..534aba8964 100644 --- a/html/cgi-bin/ids.cgi +++ b/html/cgi-bin/ids.cgi @@ -323,6 +323,40 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'save'}) { &IDS::call_suricatactrl("cron", $cgiparams{'AUTOUPDATE_INTERVAL'}); } + # Check if a ruleset is present - if not download it. + unless (%idsrules) { + # Check if the red device is active. + unless (-e "${General::swroot}/red/active") { + $errormessage = $Lang::tr{'could not download latest updates'}; + } + + # Check if enought free disk space is availabe. + if(&IDS::checkdiskspace()) { + $errormessage = "$Lang::tr{'not enough disk space'}"; + } + + # Check if any errors happend. + unless ($errormessage) { + # Lock the webpage and print notice about downloading + # a new ruleset. + &working_notice("$Lang::tr{'snort working'}"); + + # Call subfunction to download the ruleset. + if(&IDS::downloadruleset()) { + $errormessage = $Lang::tr{'could not download latest updates'}; + + # Call function to store the errormessage. + &IDS::_store_error_message($errormessage); + } else { + # Call subfunction to launch oinkmaster. + &IDS::oinkmaster(); + } + + # Perform a reload of the page. + &reload(); + } + } + # Save ruleset. } elsif ($cgiparams{'RULESET'} eq $Lang::tr{'update'}) { # Arrays to store which rulefiles have been enabled and will be used. @@ -440,7 +474,7 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'save'}) { &reload(); # Download new ruleset. -} elsif ($cgiparams{'RULESET'} eq $Lang::tr{'download new ruleset'}) { +} elsif ($cgiparams{'RULESET'} eq $Lang::tr{'update ruleset'}) { # Check if the red device is active. unless (-e "${General::swroot}/red/active") { $errormessage = $Lang::tr{'could not download latest updates'};