suricata: Remove PID file on stop

Message ID 20190501150306.4230-1-stefan.schantl@ipfire.org
State Accepted
Commit 0c52297641c96927eba3476851957ef0fe321ec8
Headers
Series suricata: Remove PID file on stop |

Commit Message

Stefan Schantl May 2, 2019, 1:03 a.m. UTC
  Force the initscript to remove the PID file when calling "stop" section.

If suricata crashes during startup, the PID file still remains and the service
cannot be started anymore until the file has been deleted.

Now when calling "stop" or "restart" the PID file will be deleted and the service
can be used again.

Fixes #12067.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 src/initscripts/system/suricata | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Michael Tremer May 3, 2019, 6:52 p.m. UTC | #1
Hello,

I am okay with the patch, but...

> On 1 May 2019, at 17:03, Stefan Schantl <stefan.schantl@ipfire.org> wrote:
> 
> Force the initscript to remove the PID file when calling "stop" section.
> 
> If suricata crashes during startup, the PID file still remains and the service
> cannot be started anymore until the file has been deleted.
> 
> Now when calling "stop" or "restart" the PID file will be deleted and the service
> can be used again.
> 
> Fixes #12067.
> 
> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
> ---
> src/initscripts/system/suricata | 3 +++
> 1 file changed, 3 insertions(+)
> 
> diff --git a/src/initscripts/system/suricata b/src/initscripts/system/suricata
> index c9f131fca..38b6a40d8 100644
> --- a/src/initscripts/system/suricata
> +++ b/src/initscripts/system/suricata
> @@ -171,6 +171,9 @@ case "$1" in
> 		# Remove suricata control socket.              
> 		rm /var/run/suricata/* >/dev/null 2>/dev/null
> 
> +		# Trash remain pid file if still exists.
> +		rm -f $PID_FILE >/dev/null 2>/dev/null
> +

Please quote variables and use {} around them.

I will soon start to reject any patches that do not follow that coding style.

Best,
-Michael

> 		# Don't report returncode of rm if suricata was not started
> 		exit 0
>         ;;
> -- 
> 2.20.1
>
  

Patch

diff --git a/src/initscripts/system/suricata b/src/initscripts/system/suricata
index c9f131fca..38b6a40d8 100644
--- a/src/initscripts/system/suricata
+++ b/src/initscripts/system/suricata
@@ -171,6 +171,9 @@  case "$1" in
 		# Remove suricata control socket.              
 		rm /var/run/suricata/* >/dev/null 2>/dev/null
 
+		# Trash remain pid file if still exists.
+		rm -f $PID_FILE >/dev/null 2>/dev/null
+
 		# Don't report returncode of rm if suricata was not started
 		exit 0
         ;;