]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
ids.cgi: Only perform actions when saving ruleset settings, if there are no error...
authorStefan Schantl <stefan.schantl@ipfire.org>
Wed, 6 Feb 2019 11:48:08 +0000 (12:48 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Wed, 6 Feb 2019 11:48:08 +0000 (12:48 +0100)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
html/cgi-bin/ids.cgi

index 388abf2d77346a5c22015225b29cf78678966c90..717e49882bd1d7ce28fc5e644549197ccc2c5a2d 100644 (file)
@@ -315,53 +315,53 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'save'}) {
        if (!$errormessage) {
                # Store settings into settings file.
                &General::writehash("$IDS::rules_settings_file", \%cgiparams);
        if (!$errormessage) {
                # Store settings into settings file.
                &General::writehash("$IDS::rules_settings_file", \%cgiparams);
-       }
-
-       # Check if the the automatic rule update hass been touched.
-       if($cgiparams{'AUTOUPDATE_INTERVAL'} ne $oldsettings{'AUTOUPDATE_INTERVAL'}) {
-               # Call suricatactrl to set the new interval.
-               &IDS::call_suricatactrl("cron", $cgiparams{'AUTOUPDATE_INTERVAL'});
-       }
 
 
-       # Check if a ruleset is present - if not or the source has been changed download it.
-       if((! %idsrules) || ($oldsettings{'RULES'} ne $cgiparams{'RULES'})) {
-               # Check if the red device is active.
-               unless (-e "${General::swroot}/red/active") {
-                       $errormessage = "$Lang::tr{'could not download latest updates'} - $Lang::tr{'system is offline'}";
+               # Check if the the automatic rule update hass been touched.
+               if($cgiparams{'AUTOUPDATE_INTERVAL'} ne $oldsettings{'AUTOUPDATE_INTERVAL'}) {
+                       # Call suricatactrl to set the new interval.
+                       &IDS::call_suricatactrl("cron", $cgiparams{'AUTOUPDATE_INTERVAL'});
                }
 
                }
 
-               # Check if enought free disk space is availabe.
-               if(&IDS::checkdiskspace()) {
-                       $errormessage = "$Lang::tr{'not enough disk space'}";
-               }
+               # Check if a ruleset is present - if not or the source has been changed download it.
+               if((! %idsrules) || ($oldsettings{'RULES'} ne $cgiparams{'RULES'})) {
+                       # Check if the red device is active.
+                       unless (-e "${General::swroot}/red/active") {
+                               $errormessage = "$Lang::tr{'could not download latest updates'} - $Lang::tr{'system is offline'}";
+                       }
 
 
-               # Check if any errors happend.
-               unless ($errormessage) {
-                       # Lock the webpage and print notice about downloading
-                       # a new ruleset.
-                       &working_notice("$Lang::tr{'snort working'}");
+                       # Check if enought free disk space is availabe.
+                       if(&IDS::checkdiskspace()) {
+                               $errormessage = "$Lang::tr{'not enough disk space'}";
+                       }
 
 
-                       # Call subfunction to download the ruleset.
-                       if(&IDS::downloadruleset()) {
-                               $errormessage = $Lang::tr{'could not download latest updates'};
+                       # 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 function to store the errormessage.
-                               &IDS::_store_error_message($errormessage);
-                       } else {
-                               # Call subfunction to launch oinkmaster.
-                               &IDS::oinkmaster();
-                       }
+                               # Call subfunction to download the ruleset.
+                               if(&IDS::downloadruleset()) {
+                                       $errormessage = $Lang::tr{'could not download latest updates'};
 
 
-                       # Check if the IDS is running.
-                       if(&IDS::ids_is_running()) {
-                               # Call suricatactrl to stop the IDS - because of the changed
-                               # ruleset - the use has to configure it before suricata can be
-                               # used again.
-                               &IDS::call_suricatactrl("stop");
-                       }
+                                       # 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();
+                               # Check if the IDS is running.
+                               if(&IDS::ids_is_running()) {
+                                       # Call suricatactrl to stop the IDS - because of the changed
+                                       # ruleset - the use has to configure it before suricata can be
+                                       # used again.
+                                       &IDS::call_suricatactrl("stop");
+                               }
+
+                               # Perform a reload of the page.
+                               &reload();
+                       }
                }
        }
 
                }
        }