From c9b07d6a0cdb54c71d5aef4a75c40d505585a0fe Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Wed, 30 Jan 2019 13:43:38 +0100 Subject: [PATCH] initscripts/suricata: Generate firewall rules on start and reload Fixes #11978 Signed-off-by: Stefan Schantl --- src/initscripts/system/suricata | 121 +++++++++++++++++++++----------- 1 file changed, 81 insertions(+), 40 deletions(-) diff --git a/src/initscripts/system/suricata b/src/initscripts/system/suricata index 99097a8e3a..b406b920ab 100644 --- a/src/initscripts/system/suricata +++ b/src/initscripts/system/suricata @@ -35,52 +35,81 @@ MASK="0x2" # PID file of suricata. PID_FILE="/var/run/suricata.pid" +# Function to get the amount of CPU cores of the system. +function get_cpu_count { + CPUCOUNT=0 + + # Loop through "/proc/cpuinfo" and count the amount of CPU cores. + while read line; do + [ "$line" ] && [ -z "${line%processor*}" ] && ((CPUCOUNT++)) + done /dev/null 2>/dev/null @@ -117,6 +152,12 @@ case "$1" in # Send SIGUSR2 to the suricata process to perform a reload # of the ruleset. kill -USR2 $(pidof suricata) + + # Flush the firewall chain. + flush_fw_chain + + # Generate firewall rules. + generate_fw_rules ;; *) -- 2.39.2