]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
suricata: Force Suricata to write a PID file again
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 10 Sep 2024 21:23:38 +0000 (23:23 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 24 Sep 2024 08:44:02 +0000 (08:44 +0000)
The PID file does not get written when Suricata is not being started in
daemon mode and therefore we need to pass it as a command line
parameter.

The initscript should not deal with the PID file when starting but needs
it to terminate the process and to check the process status.

The web UI can use the PID file again.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/suricata/suricata-watcher
html/cgi-bin/ids.cgi
src/initscripts/system/suricata

index af4defe04f4f9b7483dbe245f6ebeb3c884ec7f8..d937ef8cc9f4c6e6cdb63c90c64d9b60a9f48313 100644 (file)
@@ -24,9 +24,12 @@ PIDFILE="/var/run/suricata.pid"
 main() {
        local ret
 
+       # Suricata becomes unhappy if the PID file exists
+       unlink "${PIDFILE}" &>/dev/null
+
        while :; do
                # Launch suricata
-               /usr/bin/suricata "$@" &>/dev/null
+               /usr/bin/suricata --pidfile "${PIDFILE}" "$@" &>/dev/null
 
                # Wait until suricata is done
                ret=$?
index 34e6bf233ad06d8013164ea4b87f5da02a98976f..db05df98a9143e35fdd55c085d6ba105006a90a7 100644 (file)
@@ -1011,7 +1011,7 @@ sub show_mainpage() {
 
        &Header::ServiceStatus({
                $Lang::tr{'intrusion prevention system'} => {
-                       "process" => "Suricata-Main",
+                       "pidfile" => "/var/run/suricata.pid",
                },
        });
 
index f3aa18f23966e602e0cc3312368bf92d9aba0553..2890fa64be1ef73881fc9f48168ab793ce15e2d9 100644 (file)
@@ -159,7 +159,7 @@ case "$1" in
 
         stop)
                boot_mesg "Stopping Intrusion Detection System..."
-               killproc /usr/bin/suricata
+               killproc -p /var/run/suricata.pid /usr/bin/suricata
 
                # Flush firewall chain.
                flush_fw_chain
@@ -169,13 +169,14 @@ case "$1" in
         ;;
 
         status)
-                statusproc /usr/bin/suricata
+                PIDFILE="/var/run/suricata.pid" statusproc /usr/bin/suricata
                 ;;
 
         restart)
                 $0 stop
                 $0 start
                 ;;
+
        reload)
                # Send SIGUSR2 to the suricata process to perform a reload
                # of the ruleset.