[apache2] 01/01: Fix race condition and logical error in init script

Stefan Fritsch sf at moszumanska.debian.org
Sat May 28 09:24:44 UTC 2016


This is an automated email from the git hooks/post-receive script.

sf pushed a commit to branch jessie
in repository apache2.

commit e24275cd8997d8595b84ad0bd6c5b018473d81e8
Author: Stefan Fritsch <sf at sfritsch.de>
Date:   Sat May 28 11:23:43 2016 +0200

    Fix race condition and logical error in init script
---
 debian/apache2.init | 18 ++++++++++++------
 debian/changelog    |  7 +++++++
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/debian/apache2.init b/debian/apache2.init
index 1e25bf0..b222874 100755
--- a/debian/apache2.init
+++ b/debian/apache2.init
@@ -139,6 +139,7 @@ apache_wait_start() {
 
 apache_wait_stop() {
 	local STATUS=$1
+	local METH=$2
 
 	if [ $STATUS != 0 ] ; then
 	        return $STATUS
@@ -146,11 +147,18 @@ apache_wait_stop() {
 
 	PIDTMP=$(pidofproc -p $PIDFILE $DAEMON)
 	if [ -n "${PIDTMP:-}" ] && kill -0 "${PIDTMP:-}" 2> /dev/null; then
+
+	        if [ "$METH" = "kill" ]; then
+	            killproc -p $PIDFILE $DAEMON
+	        else
+	            $APACHE2CTL $METH > /dev/null 2>&1
+	        fi
+
 	        local i=0
 	        while kill -0 "${PIDTMP:-}" 2> /dev/null;  do
 	                if [ $i = '60' ]; then
-	                        break
 	                        STATUS=2
+	                        break
 	                fi
 	                [ "$VERBOSE" != no ] && log_progress_msg "."
 	                sleep 1
@@ -223,15 +231,13 @@ do_stop()
 	fi
 
 	if [ $AP_RET = 2 ] && apache_conftest ; then
-	        $APACHE2CTL $STOP > /dev/null 2>&1
-	        apache_wait_stop $?
+	        apache_wait_stop $? $STOP
 	        return $?
 	else
 	        if [ $AP_RET = 2 ]; then
-					clear_error_msg
+	                clear_error_msg
 	                APACHE2_INIT_MESSAGE="The apache2$DIR_SUFFIX configtest failed, so we are trying to kill it manually. This is almost certainly suboptimal, so please make sure your system is working as you'd expect now!"
-	                killproc -p $PIDFILE $DAEMON
-	                apache_wait_stop $?
+	                apache_wait_stop $? "kill"
 	                return $?
 	        elif [ $AP_RET = 1 ] ; then
 	                APACHE2_INIT_MESSAGE="There are processes named 'apache2' running which do not match your pid file which are left untouched in the name of safety, Please review the situation by hand".
diff --git a/debian/changelog b/debian/changelog
index 3396876..361f92a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+apache2 (2.4.10-10+deb8u5) UNRELEASED; urgency=medium
+
+  * Fix race condition and logical error in init script. Thanks to Thomas
+    Stangner for the patch. Closes: #822144
+
+ -- Stefan Fritsch <sf at debian.org>  Sat, 28 May 2016 11:23:21 +0200
+
 apache2 (2.4.10-10+deb8u4) jessie; urgency=medium
 
   * Add versioned replaces/breaks for libapache2-mod-macro to apache2,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-apache/apache2.git



More information about the Pkg-apache-commits mailing list