Blame SOURCES/httpd-2.4.1-apctl.patch

008793
008793
- fail gracefully if links is not installed on target system
008793
- source sysconfig/httpd for custom env. vars etc.
008793
- make httpd -t work even in SELinux
008793
- pass $OPTIONS to all $HTTPD invocation
008793
008793
Upstream-HEAD: vendor
008793
Upstream-2.0: vendor
008793
Upstream-Status: Vendor-specific changes for better initscript integration
008793
008793
--- httpd-2.4.1/support/apachectl.in.apctl
008793
+++ httpd-2.4.1/support/apachectl.in
008793
@@ -44,19 +44,25 @@ ARGV="$@"
008793
 # the path to your httpd binary, including options if necessary
008793
 HTTPD='@exp_sbindir@/@progname@'
008793
 #
008793
-# pick up any necessary environment variables
008793
-if test -f @exp_sbindir@/envvars; then
008793
-  . @exp_sbindir@/envvars
008793
-fi
008793
 #
008793
 # a command that outputs a formatted text version of the HTML at the
008793
 # url given on the command line.  Designed for lynx, however other
008793
 # programs may work.  
008793
-LYNX="@LYNX_PATH@ -dump"
008793
+if [ -x "@LYNX_PATH@" ]; then
008793
+  LYNX="@LYNX_PATH@ -dump"
008793
+else
008793
+  LYNX=none
008793
+fi
008793
 #
008793
 # the URL to your server's mod_status status page.  If you do not
008793
 # have one, then status and fullstatus will not work.
008793
 STATUSURL="http://localhost:@PORT@/server-status"
008793
+
008793
+# Source /etc/sysconfig/httpd for $HTTPD setting, etc.
008793
+if [ -r /etc/sysconfig/httpd ]; then
008793
+   . /etc/sysconfig/httpd
008793
+fi
008793
+
008793
 #
008793
 # Set this variable to a command that increases the maximum
008793
 # number of file descriptors allowed per child process. This is
008793
@@ -76,9 +82,27 @@ if [ "x$ARGV" = "x" ] ; then 
008793
     ARGV="-h"
008793
 fi
008793
 
008793
+function checklynx() {
008793
+if [ "$LYNX" = "none" ]; then
008793
+   echo "The 'links' package is required for this functionality."
008793
+   exit 8
008793
+fi
008793
+}
008793
+
008793
+function testconfig() {
008793
+# httpd is denied terminal access in SELinux, so run in the
008793
+# current context to get stdout from $HTTPD -t.
008793
+if test -x /usr/sbin/selinuxenabled && /usr/sbin/selinuxenabled; then
008793
+  runcon -- `id -Z` $HTTPD $OPTIONS -t
008793
+else
008793
+  $HTTPD $OPTIONS -t
008793
+fi
008793
+ERROR=$?
008793
+}
008793
+
008793
 case $ACMD in
008793
 start|stop|restart|graceful|graceful-stop)
008793
-    $HTTPD -k $ARGV
008793
+    $HTTPD $OPTIONS -k $ARGV
008793
     ERROR=$?
008793
     ;;
008793
 startssl|sslstart|start-SSL)
008793
@@ -88,17 +112,18 @@ startssl|sslstart|start-SSL)
008793
     ERROR=2
008793
     ;;
008793
 configtest)
008793
-    $HTTPD -t
008793
-    ERROR=$?
008793
+    testconfig
008793
     ;;
008793
 status)
008793
+    checklynx
008793
     $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } '
008793
     ;;
008793
 fullstatus)
008793
+    checklynx
008793
     $LYNX $STATUSURL
008793
     ;;
008793
 *)
008793
-    $HTTPD "$@"
008793
+    $HTTPD $OPTIONS "$@"
008793
     ERROR=$?
008793
 esac
008793