From b86b48c4a2a3293c0e9a8cb74e01f1827c3be904 Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Thu, 14 Mar 2019 10:30:15 +0000 Subject: [PATCH] apachectl: cleanup and replace script wholesale (#1641237) * drop "apachectl fullstatus" support * run systemctl with --no-pager option * implement graceful&graceful-stop by signal directly run "httpd -t" from legacy action script Resolves: rhbz#1641237 --- action-configtest.sh | 2 +- action-graceful.sh | 2 +- apachectl.sh | 62 ++++++++++++++++++++++ httpd-2.4.1-apctl.patch | 94 --------------------------------- httpd-2.4.34-apctlsystemd.patch | 63 ---------------------- httpd.spec | 18 ++++--- 6 files changed, 75 insertions(+), 166 deletions(-) create mode 100755 apachectl.sh delete mode 100644 httpd-2.4.1-apctl.patch delete mode 100644 httpd-2.4.34-apctlsystemd.patch diff --git a/action-configtest.sh b/action-configtest.sh index 6685b0a..711d9cd 100644 --- a/action-configtest.sh +++ b/action-configtest.sh @@ -1,2 +1,2 @@ #!/bin/sh -exec /sbin/apachectl configtest "$@" +exec /usr/sbin/httpd -t diff --git a/action-graceful.sh b/action-graceful.sh index dc68b2e..4976087 100644 --- a/action-graceful.sh +++ b/action-graceful.sh @@ -1,2 +1,2 @@ #!/bin/sh -exec /sbin/apachectl graceful "$@" +exec /sbin/apachectl graceful diff --git a/apachectl.sh b/apachectl.sh new file mode 100755 index 0000000..ee2dba8 --- /dev/null +++ b/apachectl.sh @@ -0,0 +1,62 @@ +#!/usr/bin/sh +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if [ "x$1" = "x-k" ]; then + shift +fi + +ACMD="$1" +ARGV="$@" +SVC='httpd.service' + +if [ "x$2" != "x" ] ; then + echo Passing arguments to httpd using apachectl is no longer supported. + echo You can only start/stop/restart httpd using this script. + echo To pass extra arguments to httpd, see the $SVC'(8)' + echo man page. + exit 1 +fi + +case $ACMD in +start|stop|restart|status) + /usr/bin/systemctl --no-pager $ACMD $SVC + ERROR=$? + ;; +graceful) + if /usr/bin/systemctl -q is-active $SVC; then + /usr/bin/systemctl kill --signal=SIGUSR1 $SVC + else + /usr/bin/systemctl start $SVC + fi + ERROR=$? + ;; +graceful-stop) + /usr/bin/systemctl kill --signal=SIGWINCH $SVC + ERROR=$? + ;; +configtest) + /usr/sbin/service ${SVC/.service//} $ACMD + ERROR=$? + ;; +*) + echo apachectl: The \"$ACMD\" option is not supported. 1>&2 + ERROR=2 + ;; +esac + +exit $ERROR + diff --git a/httpd-2.4.1-apctl.patch b/httpd-2.4.1-apctl.patch deleted file mode 100644 index b31c3c5..0000000 --- a/httpd-2.4.1-apctl.patch +++ /dev/null @@ -1,94 +0,0 @@ - -- fail gracefully if links is not installed on target system -- source sysconfig/httpd for custom env. vars etc. -- make httpd -t work even in SELinux -- pass $OPTIONS to all $HTTPD invocation - -Upstream-HEAD: vendor -Upstream-2.0: vendor -Upstream-Status: Vendor-specific changes for better initscript integration - ---- httpd-2.4.1/support/apachectl.in.apctl -+++ httpd-2.4.1/support/apachectl.in -@@ -44,19 +44,25 @@ ARGV="$@" - # the path to your httpd binary, including options if necessary - HTTPD='@exp_sbindir@/@progname@' - # --# pick up any necessary environment variables --if test -f @exp_sbindir@/envvars; then -- . @exp_sbindir@/envvars --fi - # - # a command that outputs a formatted text version of the HTML at the - # url given on the command line. Designed for lynx, however other - # programs may work. --LYNX="@LYNX_PATH@ -dump" -+if [ -x "@LYNX_PATH@" ]; then -+ LYNX="@LYNX_PATH@ -dump" -+else -+ LYNX=none -+fi - # - # the URL to your server's mod_status status page. If you do not - # have one, then status and fullstatus will not work. - STATUSURL="http://localhost:@PORT@/server-status" -+ -+# Source /etc/sysconfig/httpd for $HTTPD setting, etc. -+if [ -r /etc/sysconfig/httpd ]; then -+ . /etc/sysconfig/httpd -+fi -+ - # - # Set this variable to a command that increases the maximum - # number of file descriptors allowed per child process. This is -@@ -76,9 +82,27 @@ if [ "x$ARGV" = "x" ] ; then - ARGV="-h" - fi - -+function checklynx() { -+if [ "$LYNX" = "none" ]; then -+ echo "The 'links' package is required for this functionality." -+ exit 8 -+fi -+} -+ -+function testconfig() { -+# httpd is denied terminal access in SELinux, so run in the -+# current context to get stdout from $HTTPD -t. -+if test -x /usr/sbin/selinuxenabled && /usr/sbin/selinuxenabled; then -+ runcon -- `id -Z` $HTTPD $OPTIONS -t -+else -+ $HTTPD $OPTIONS -t -+fi -+ERROR=$? -+} -+ - case $ACMD in - start|stop|restart|graceful|graceful-stop) -- $HTTPD -k $ARGV -+ $HTTPD $OPTIONS -k $ARGV - ERROR=$? - ;; - startssl|sslstart|start-SSL) -@@ -88,17 +112,18 @@ startssl|sslstart|start-SSL) - ERROR=2 - ;; - configtest) -- $HTTPD -t -- ERROR=$? -+ testconfig - ;; - status) -+ checklynx - $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } ' - ;; - fullstatus) -+ checklynx - $LYNX $STATUSURL - ;; - *) -- $HTTPD "$@" -+ $HTTPD $OPTIONS "$@" - ERROR=$? - esac - diff --git a/httpd-2.4.34-apctlsystemd.patch b/httpd-2.4.34-apctlsystemd.patch deleted file mode 100644 index 20d7101..0000000 --- a/httpd-2.4.34-apctlsystemd.patch +++ /dev/null @@ -1,63 +0,0 @@ - -Make apachectl run via systemctl. - -Note: "apachectl graceful" is documented to start httpd if not running. - -Upstream-Status: vendor specific patch - ---- httpd-2.4.34/support/apachectl.in.apctlsystemd -+++ httpd-2.4.34/support/apachectl.in -@@ -58,11 +58,6 @@ - # have one, then status and fullstatus will not work. - STATUSURL="http://localhost:@PORT@/server-status" - --# Source /etc/sysconfig/httpd for $HTTPD setting, etc. --if [ -r /etc/sysconfig/httpd ]; then -- . /etc/sysconfig/httpd --fi -- - # - # Set this variable to a command that increases the maximum - # number of file descriptors allowed per child process. This is -@@ -100,9 +95,28 @@ - ERROR=$? - } - -+if [ "x$2" != "x" ] ; then -+ echo Passing arguments to httpd using apachectl is no longer supported. -+ echo You can only start/stop/restart httpd using this script. -+ echo "To pass extra arguments to httpd, see the httpd.service(8)" -+ echo man page. -+fi -+ - case $ACMD in --start|stop|restart|graceful|graceful-stop) -- $HTTPD $OPTIONS -k $ARGV -+start|stop|restart|status) -+ /usr/bin/systemctl $ACMD httpd.service -+ ERROR=$? -+ ;; -+graceful) -+ if /usr/bin/systemctl -q is-active httpd.service; then -+ /usr/bin/systemctl reload httpd.service -+ else -+ /usr/bin/systemctl start httpd.service -+ fi -+ ERROR=$? -+ ;; -+graceful-stop) -+ /usr/bin/systemctl stop httpd.service - ERROR=$? - ;; - startssl|sslstart|start-SSL) -@@ -114,10 +128,6 @@ - configtest) - testconfig - ;; --status) -- checklynx -- $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } ' -- ;; - fullstatus) - checklynx - $LYNX $STATUSURL diff --git a/httpd.spec b/httpd.spec index b7520a2..d8f2d02 100644 --- a/httpd.spec +++ b/httpd.spec @@ -13,7 +13,7 @@ Summary: Apache HTTP Server Name: httpd Version: 2.4.38 -Release: 5%{?dist} +Release: 6%{?dist} URL: https://httpd.apache.org/ Source0: https://www.apache.org/dist/httpd/httpd-%{version}.tar.bz2 Source1: index.html @@ -45,7 +45,6 @@ Source26: 10-listen443.conf Source27: httpd.socket Source28: 00-optional.conf Source29: 01-md.conf -# Documentation Source30: README.confd Source31: README.confmod Source32: httpd.service.xml @@ -57,11 +56,10 @@ Source42: httpd-init.service Source43: httpd-ssl-gencerts Source44: httpd@.service Source45: config.layout +Source46: apachectl.sh # build/scripts patches -Patch1: httpd-2.4.1-apctl.patch Patch2: httpd-2.4.9-apxs.patch Patch3: httpd-2.4.1-deplibs.patch -Patch6: httpd-2.4.34-apctlsystemd.patch # Needed for socket activation and mod_systemd patch Patch19: httpd-2.4.25-detect-systemd.patch # Features/functional changes @@ -210,10 +208,8 @@ interface for storing and accessing per-user session data. %prep %setup -q -%patch1 -p1 -b .apctl %patch2 -p1 -b .apxs %patch3 -p1 -b .deplibs -%patch6 -p1 -b .apctlsystemd %patch19 -p1 -b .detectsystemd @@ -482,7 +478,8 @@ install -m755 $RPM_SOURCE_DIR/httpd-ssl-pass-dialog \ install -m755 $RPM_SOURCE_DIR/httpd-ssl-gencerts \ $RPM_BUILD_ROOT%{_libexecdir}/httpd-ssl-gencerts -# Install action scripts +# Install scripts +install -p -m 755 $RPM_SOURCE_DIR/apachectl.sh $RPM_BUILD_ROOT%{_sbindir}/apachectl mkdir -p $RPM_BUILD_ROOT%{_libexecdir}/initscripts/legacy-actions/httpd for f in graceful configtest; do install -p -m 755 $RPM_SOURCE_DIR/action-${f}.sh \ @@ -736,6 +733,13 @@ exit $rv %{_rpmconfigdir}/macros.d/macros.httpd %changelog +* Thu Feb 28 2019 Joe Orton - 2.4.38-6 +- apachectl: cleanup and replace script wholesale (#1641237) + * drop "apachectl fullstatus" support + * run systemctl with --no-pager option + * implement graceful&graceful-stop by signal directly +- run "httpd -t" from legacy action script + * Tue Feb 05 2019 Lubos Uhliarik - 2.4.38-5 - segmentation fault fix (FIPS)