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

Bug#475150: apache2.2-common: No possibility to supply defines (-D) on startup



Package: apache2.2-common
Version: 2.2.3-4+etch4
Severity: minor
Tags: patch


It is not possible to set defines for use in <IfDefine name>
directive.

The attached patch add a variable APACHE_DEFINES to /etc/default/apache2
which is evaluated at startup and passes the defines to apachectl.


-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-028stab053-dl3xx-openvz
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages apache2.2-common depends on:
ii  apache2-utils              2.2.3-4+etch4 utility programs for webservers
ii libmagic1 4.17-5etch3 File type determination library us ii lsb-base 3.1-23.2etch1 Linux Standard Base 3.1 init scrip ii mime-support 3.39-1 MIME files 'mime.types' & 'mailcap
ii  net-tools                  1.60-17       The NET-3 networking toolkit
ii  procps                     1:3.2.7-3     /proc file system utilities

apache2.2-common recommends no packages.

-- no debconf information

diff -urN etc_org/default/apache2 etc/default/apache2
--- etc_org/etc/default/apache2	2008-04-08 14:03:26.000000000 +0000
+++ etc/default/apache2	2008-04-08 14:45:18.000000000 +0000
@@ -1,2 +1,4 @@
 # 0 = start on boot; 1 = don't start on boot
 NO_START=0
+# Pass defines to apache (e.g. -D Harden)
+APACHE_DEFINES=""
diff -urN etc_org/init.d/apache2 etc/init.d/apache2
--- etc_org/init.d/apache2	2008-01-31 08:41:24.000000000 +0000
+++ etc/init.d/apache2	2008-04-08 14:37:22.000000000 +0000
@@ -117,6 +117,21 @@
 	fi
 }
 
+apache_start() {
+	DEFINES="";
+	if [ "$APACHE_DEFINES" != "" ] ; then
+		for i in ${APACHE_DEFINES} ;do
+			DEFINES+="-D $i ";
+		done
+	fi
+
+	if $APACHE2CTL $DEFINES -k start; then
+		return 0
+	else
+		return 1
+	fi
+}
+
 # Stupid hack to keep lintian happy. (Warrk! Stupidhack!).
 case $1 in
 	start)
@@ -126,7 +141,7 @@
 		#ssl_scache shouldn't be here if we're just starting up.
 		[ -f /var/run/apache2/ssl_scache ] && rm -f /var/run/apache2/*ssl_scache*
 		log_begin_msg "Starting web server (apache2)..."
-		if $APACHE2CTL start; then
+		if apache_start; then
                         log_end_msg 0
                 else
                         log_end_msg 1
@@ -160,11 +175,11 @@
 		if ! apache_sync_stop; then
                         log_end_msg 1
                 fi
-		if $APACHE2CTL start; then
-                        log_end_msg 0
-                else
-                        log_end_msg 1
-                fi
+		if apache_start ; then
+			log_end_msg 0
+		else
+			log_end_msg 1
+		fi
 	;;
 	*)
 		log_success_msg "Usage: /etc/init.d/apache2 {start|stop|restart|reload|force-reload}"

Reply to: