]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/ids.cgi
time.cgi: Use new perl system functions
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / ids.cgi
index 2a8a7cb261af83162f6c7fc5378325ca48ca4cab..85c5ddd86604b7df6899390d6283639ec7fec4bf 100644 (file)
@@ -2,7 +2,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007-2018  IPFire Team  <info@ipfire.org>                     #
+# Copyright (C) 2007-2020  IPFire Team  <info@ipfire.org>                     #
 #                                                                             #
 # This program is free software: you can redistribute it and/or modify        #
 # it under the terms of the GNU General Public License as published by        #
@@ -29,6 +29,7 @@ require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
 require "${General::swroot}/ids-functions.pl";
+require "${General::swroot}/network-functions.pl";
 
 my %color = ();
 my %mainsettings = ();
@@ -43,11 +44,11 @@ my %ignored=();
 
 # Read-in main settings, for language, theme and colors.
 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
-&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
+&General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color);
 
 # Get the available network zones, based on the config type of the system and store
 # the list of zones in an array.
-my @network_zones = &IDS::get_available_network_zones();
+my @network_zones = &Network::get_available_network_zones();
 
 # Check if openvpn is started and add it to the array of network zones.
 if ( -e "/var/run/openvpn.pid") {
@@ -412,8 +413,17 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'save'}) {
        # Hash to store the user-enabled and disabled sids.
        my %enabled_disabled_sids;
 
+       # Store if a restart of suricata is required.
+       my $suricata_restart_required;
+
        # Loop through the hash of idsrules.
        foreach my $rulefile(keys %idsrules) {
+               # Check if the state of the rulefile has been changed.
+               unless ($cgiparams{$rulefile} eq $idsrules{$rulefile}{'Rulefile'}{'State'}) {
+                       # A restart of suricata is required to apply the changes of the used rulefiles.
+                       $suricata_restart_required = 1;
+               }
+
                # Check if the rulefile is enabled.
                if ($cgiparams{$rulefile} eq "on") {
                        # Add rulefile to the array of enabled rulefiles.
@@ -513,8 +523,14 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'save'}) {
 
        # Check if the IDS is running.
        if(&IDS::ids_is_running()) {
-               # Call suricatactrl to perform a reload.
-               &IDS::call_suricatactrl("reload");
+               # Check if a restart of suricata is required.
+               if ($suricata_restart_required) {
+                       # Call suricatactrl to perform the restart.
+                       &IDS::call_suricatactrl("restart");
+               } else {
+                       # Call suricatactrl to perform a reload.
+                       &IDS::call_suricatactrl("reload");
+               }
        }
 
        # Reload page.
@@ -610,6 +626,9 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'save'}) {
        # Generate file to the store the DNS servers.
        &IDS::generate_dns_servers_file();
 
+       # Generate file to store the HTTP ports.
+       &IDS::generate_http_ports_file();
+
        # Write the modify sid's file and pass the taken ruleaction.
        &IDS::write_modify_sids_file();