From 5cac32e038c705facfe6e6cc4069569e1ed0cc6d Mon Sep 17 00:00:00 2001 From: Glenn Aaldering Date: Thu, 9 Feb 2012 18:33:14 +0100 Subject: [PATCH] Making sure that the status command gives the correct exit code when fail2ban is not running. --- debian/fail2ban.init | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/debian/fail2ban.init b/debian/fail2ban.init index 70a85f63..0894b1ce 100755 --- a/debian/fail2ban.init +++ b/debian/fail2ban.init @@ -15,6 +15,8 @@ # Author: Aaron Isotton # Modified: by Yaroslav Halchenko # reindented + minor corrections + to work on sarge without modifications +# Modified: by Glenn Aaldering +# added exit codes for status command # PATH=/usr/sbin:/usr/bin:/sbin:/bin DESC="authentication failure monitor" @@ -221,14 +223,14 @@ case "$command" in 255) check_socket case $? in - 1) log_warning_msg " $NAME is not running" ;; - 0) log_failure_msg " $NAME is not running but $SOCKFILE exists" ;; - 2) log_failure_msg " $SOCKFILE not readable, status of $NAME is unknown";; - 3) log_failure_msg " $SOCKFILE exists but not a socket, status of $NAME is unknown";; - *) report_bug "Unknown return code from $NAME:check_socket.";; + 1) log_warning_msg " $NAME is not running" && exit 3 ;; + 0) log_failure_msg " $NAME is not running but $SOCKFILE exists" && exit 3 ;; + 2) log_failure_msg " $SOCKFILE not readable, status of $NAME is unknown" && exit 3 ;; + 3) log_failure_msg " $SOCKFILE exists but not a socket, status of $NAME is unknown" && exit 3 ;; + *) report_bug "Unknown return code from $NAME:check_socket." && exit 4 ;; esac ;; - *) report_bug "Unknown $NAME status code" + *) report_bug "Unknown $NAME status code" && exit 4 esac ;; *)