Package: apache2-common Version: 2.2.3-2 Severity: important Tags: patch In /etc/init.d/apache2 (my comments are after # sign):
pidof_apache() { ... # This loop returns from procedure with first PID it encounters in # existing .pid file no matter PidFile is from the right source or not. # So what if the .pid file is stalled and PidFile source is wrong? for PFILE in `grep ^PidFile /etc/apache2/* -r | awk '{print $2}'`; do if [ -e $PFILE ]; then cat $PFILE return 0 fi done ... for i in $PIDS; do # $PID is always empty string, it was never used before. This matter with # useless REALPID initialization make impression that the file was published # in the middle of development process ;) if [ "$i" = "$PID" ]; then My patch fixes these issues trying to follow the orginal thought. Though again, it is not the most proper (but rather fastest) way to do the thing. ;)
--- apache2.orig 2006-10-08 12:38:25.000000000 +0800 +++ apache2 2006-10-30 11:53:50.000000000 +0700 @@ -36,29 +36,32 @@ pidof_apache() { # classified as good/unknown feature PIDS=`pidof apache2` || true - PID="" - # let's try to find the pid file - # apache2 allows more than PidFile entry in the config but only - # the last found in the config is used + # apache2 allows more than PidFile entry + # most simple way is to check all of them + + PIDS2="" + for PFILE in `grep ^PidFile /etc/apache2/* -r | awk '{print $2}'`; do - if [ -e $PFILE ]; then - cat $PFILE - return 0 - fi + [ -e $PFILE ] && PIDS2="$PIDS2 `cat $PFILE`" done - REALPID=0 + # if there is a pid we need to verify that belongs to apache2 # for real for i in $PIDS; do - if [ "$i" = "$PID" ]; then + # may be it is not the right way to make second dimension + # for really huge setups with hundreds of apache processes + # and tons of garbage in /etc/apache2... or is it? + for j in $PIDS2; do + if [ "$i" = "$j" ]; then # in this case the pid stored in the # pidfile matches one of the pidof apache # so a simple kill will make it - echo $PID + echo $i return 0 fi done + done return 1 }