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