From 1ee79ea2287c05476ad5cb3e596d2c495cc2a066d7e4462c4fc164460bac02d9 Mon Sep 17 00:00:00 2001 From: Roman Drahtmueller Date: Fri, 18 Nov 2011 15:55:03 +0000 Subject: [PATCH] - update to /etc/init.d/apache2: handle reload with deleted binaries after package update more thoughtfully: If the binaries have been replaced, then a dlopen(3) on the apache modules is prone to fail. => Don't reload then, but complain and fail. Especially important for logrotate! OBS-URL: https://build.opensuse.org/package/show/Apache/apache2?expand=0&rev=350 --- apache2.changes | 9 +++++++++ rc.apache2 | 26 +++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/apache2.changes b/apache2.changes index 7d07a99..93ad464 100644 --- a/apache2.changes +++ b/apache2.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Fri Nov 18 15:04:12 CET 2011 - draht@suse.de + +- update to /etc/init.d/apache2: handle reload with deleted + binaries after package update more thoughtfully: If the binaries + have been replaced, then a dlopen(3) on the apache modules is + prone to fail. => Don't reload then, but complain and fail. + Especially important for logrotate! + ------------------------------------------------------------------- Fri Oct 7 17:11:56 CEST 2011 - draht@suse.de diff --git a/rc.apache2 b/rc.apache2 index 08e2aa6..a83f564 100644 --- a/rc.apache2 +++ b/rc.apache2 @@ -6,8 +6,8 @@ # Copyright (c) 2004(?), 2005, 2006, 2007, 2008 SUSE Linux Products GmbH # # Authors: Rolf Haberrecker , 2001 -# Peter Poeml , 2002, 2003, 2004, 2005, 2006, 2007, -# 2008, 2009, 2010 +# Peter Poeml , 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011. +# Roman Drahtmueller , 2010, 2011, 2012. # # # /etc/init.d/apache2 @@ -162,6 +162,8 @@ case "$action" in echo -n "(not running)" else pid=$(<$pidfile) + # re-read exe symlink, it could be (deleted) in the meanwhile. + apache_bin=$(readlink /proc/$pid/exe 2>/dev/null) kill -TERM $pid 2>/dev/null case $? in 1) echo -n "(not running)";; @@ -175,7 +177,7 @@ case "$action" in if ! test -f /proc/$pid/exe; then break fi - if test "$(readlink /proc/$pid/exe 2>/dev/null)" = $apache_bin; then + if test "$(readlink /proc/$pid/exe 2>/dev/null)" = "$apache_bin"; then usleep 500000 else break @@ -261,7 +263,25 @@ case "$action" in rc_status ;; reload|force-reload|graceful) + # check if there is a deleted binary. If there is, then logrotate + # or other occasions will fail to reload, as dlopen(3) of apache + # modules is prone to fail due to symbol mismatches. + # in this case, we only complain and fail. + if [ ! -f $pidfile -a -f $pidfile.rpmsave ]; then mv $pidfile.rpmsave $pidfile; fi + executable=$( readlink /proc/$(cat $pidfile)/exe 2> /dev/null ) + case "$executable" in + *httpd*delete*) + echo -n "Reload httpd2 after package update: ignoring request. Please do a manual restart explicitly! " + rc_failed 1 + rc_status -v + rc_exit + ;; + *) + ;; + esac + echo -n "Reload httpd2 (graceful restart)" + cmdline=$(echo $apache_bin -f $httpd_conf $server_flags "$@") if eval $cmdline -t &> $logdir/rc$pname.out; then killproc -USR1 $apache_bin || return=$rc_failed