[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#460105: /etc/init.d/apache2 greps excessively for PidFile



Package: Apache2 
Version: 2.2.6-3
User: nvalcarcel@ubuntu-pe.org
Usertags: origin-ubuntu hardy ubuntu-patch

/etc/init.d/apache2 does a "grep ^PidFile /etc/apache2/* -r". 

this grep has two (and others) main disadvantages:
1. It reads an unkown number of files without reason (remember: a
dedicated host might have hundreds of files and symlinks in
sites-enabled|sites-available.
2. It would even parse a file like apache.conf.backup and check if there
is a pid to kill.

Therefore I'd only parse .conf files or better apache2.conf as this is
the place to configure the location of the PidFile. Besides this would
solve the mentioned problem.

Or ideally being more intelligent about which files to look at, e.g.
*.conf...
Originaly reported on:
https://bugs.edge.launchpad.net/ubuntu/+source/apache2/+bug/112991

Attaching patch who solves it

-- 
aka nxvl
Peruvian LoCo Team
Key fingerprint = 8104 21CE A580 7EB7 5184  8DFF 6A3A D5DA 24DC 6AF5
gpg --keyserver keyserver.ubuntu.com --recv-keys 24DC6AF5
--- apache2-2.2.6/debian/apache2.2-common.apache2.init
+++ apache2-2.2.6/debian/apache2.2-common.apache2.init
@@ -72,7 +72,7 @@
 
     PIDS2=""
 
-    for PFILE in `grep ^PidFile /etc/apache2/* -r | awk '{print $2}'`; do
+    for PFILE in `find /etc/apache2/ -type f -name '*.conf' -print0 | xargs -0 grep ^PidFile | awk '{print $2}'`; do
 	[ -e $PFILE ] && PIDS2="$PIDS2 `cat $PFILE`"
     done
 

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: