Fix porting error that prevented PHP SAPIs to be restarted on upgrade

Thanks goes to Stefan Schlesinger, who debugged the issue and noticed the
apache2->php porting error where $rcd_action was tested, but never set,
thus effectively disabling dpkg-trigger.
This commit is contained in:
Ondřej Surý 2020-01-22 13:23:35 +01:00
parent 67a973b427
commit c3ef50bfeb

View file

@ -37,11 +37,6 @@
# will be defined by php-maintscript-helper
# to avoid inclusion loops. Do not set this
# variable manually
# * PHP_NEED_ACTION:
# will be defined if a function call wants to
# override the behavior of php_needs_action.
# Do not rely on this variable. It is considered
# an implementation detail.
# * PHP_MAINTSCRIPT_NAME
# * PHP_MAINTSCRIPT_PACKAGE
# * PHP_MAINTSCRIPT_METHOD
@ -102,7 +97,7 @@ else
fi
case "$PHP_MAINTSCRIPT_METHOD" in
install|upgrade|abort-upgrade|configure|abort-remove|abort-remove|abort-deconfigure|remove|failed-upgrade|purge|disappear|abort-install)
install|upgrade|abort-upgrade|configure|abort-remove|abort-deconfigure|remove|failed-upgrade|purge|disappear|abort-install)
# yay - recognized script
;;
*)
@ -141,9 +136,9 @@ fi
# this function always returns 0
# Since: 5.5.0+dfsg-7
php_msg()
{
local PRIORITY="$1"
local MSG="$2"
(
PRIORITY="$1"
MSG="$2"
case "$PRIORITY" in
debug|info|notice|warning|err|crit|alert|emerg)
;;
@ -151,11 +146,13 @@ php_msg()
PRIORITY="warning"
;;
esac
[ -z "$PHP_MAINTSCRIPT_HELPER_QUIET" ] && ( [ -n "${PHP_MAINTSCRIPT_DEBUG:-}" ] || [ "$PRIORITY" != "debug" ] ) && echo "$MSG" >&2
if [ -n "${PHP_MAINTSCRIPT_DEBUG:-}" ] || [ "$PRIORITY" != "debug" ]; then
[ -z "$PHP_MAINTSCRIPT_HELPER_QUIET" ] && echo "$MSG" >&2
fi
[ -x /usr/bin/logger ] || return 0
local LOGGER="/usr/bin/logger -p daemon.$PRIORITY -t $PHP_MAINTSCRIPT_PACKAGE "
LOGGER="/usr/bin/logger -p daemon.$PRIORITY -t $PHP_MAINTSCRIPT_PACKAGE "
$LOGGER "$MSG" || return 0
}
)
#
# Function php_invoke
@ -181,41 +178,36 @@ php_msg()
# 1 otherwise
# Since: 5.5.0+dsfg-7
php_invoke()
{
local CMD=$1
local VERSION=$2
local SAPI=$3
local MOD=$4
local check_switch=""
local invoke_string=""
local rcd_action=""
local rcd_scripts=""
local sapi_list=""
(
CMD=$1
VERSION=$2
SAPI=$3
MOD=$4
sapi_list=""
[ -x "/usr/sbin/php$CMD" ] || return 1
[ -x "/usr/sbin/phpquery" ] || return 1
case "$VERSION" in
ALL)
version_list=$(phpquery -V)
;;
*)
version_list="$VERSION"
# FIXME - check if the version is supported
;;
ALL)
version_list=$(phpquery -V)
;;
*)
version_list="$VERSION"
# FIXME - check if the version is supported
;;
esac
for version in $version_list; do
case "$SAPI" in
apache2|apache2filter|fpm|cli|cgi|embed|phpdbg)
sapi_list="$SAPI"
;;
;;
ALL)
sapi_list=$(phpquery -S -v $version)
sapi_list=$(phpquery -S -v "$version")
case "$CMD" in
enmod|dismod)
php$CMD -q -v "$version" -m -r "$MOD" || return 1
"php$CMD" -q -v "$version" -m -r "$MOD" || return 1
;;
*)
return 1
@ -230,11 +222,11 @@ php_invoke()
for sapi in $sapi_list; do
case "$CMD" in
enmod)
local phpquery_ret=0
phpquery_ret=0
phpquery -v "$version" -s "$sapi" -m "$MOD" > /dev/null 2>&1 || phpquery_ret=$?
if [ "$phpquery_ret" -eq 0 ] ; then
# configuration is already enabled
php$CMD -m -v "$version" -s "$sapi" -q "$MOD" > /dev/null 2>&1 || return 1
"php$CMD" -m -v "$version" -s "$sapi" -q "$MOD" > /dev/null 2>&1 || return 1
php_msg "debug" "php_invoke $MOD: already enabled for PHP $version $sapi sapi"
PHP_NEED_ACTION=1
elif [ "$phpquery_ret" -eq 32 ] ; then
@ -246,21 +238,21 @@ php_invoke()
# a) we have no clue about the module (e.g. for upgrades prior to maintscript-helper
# b) it's a fresh install
PHP_NEED_ACTION=1
php$CMD -m -v "$version" -s "$sapi" -q "$MOD" > /dev/null 2>&1 || return 1
"php$CMD" -m -v "$version" -s "$sapi" -q "$MOD" > /dev/null 2>&1 || return 1
php_msg "debug" "php_invoke: Enabled module $MOD for $sapi sapi"
fi
;;
dismod)
local phpquery_ret=0
phpquery_ret=0
phpquery -v "$version" -s "$sapi" -m "$MOD" > /dev/null 2>&1 || phpquery_ret=$?
if [ "$phpquery_ret" -eq 0 ] ; then
if [ "$PHP_MAINTSCRIPT_NAME" = 'postrm' ] && [ "$PHP_MAINTSCRIPT_METHOD" = "purge" ] ; then
php$CMD -p -f -v "$version" -s "$sapi" -q "$MOD" || return 1
"php$CMD" -p -f -v "$version" -s "$sapi" -q "$MOD" || return 1
php_msg "debug" "php_invoke $PHP_MAINTSCRIPT_NAME: Purging module $MOD for PHP $version $sapi sapi"
PHP_NEED_ACTION=1
elif [ "$PHP_MAINTSCRIPT_NAME" = 'postrm' ] || [ "$PHP_MAINTSCRIPT_NAME" = 'prerm' ] || [ "$PHP_MAINTSCRIPT_NAME" = 'preinst' ] ; then
if [ "$PHP_MAINTSCRIPT_METHOD" = "remove" ] || [ "$PHP_MAINTSCRIPT_METHOD" = "upgrade" ] ; then
php$CMD -m -f -v "$version" -s "$sapi" -q "$MOD" || return 1
"php$CMD" -m -f -v "$version" -s "$sapi" -q "$MOD" || return 1
php_msg "debug" "php_invoke $PHP_MAINTSCRIPT_NAME: Disabled module $MOD for PHP $version $sapi sapi"
PHP_NEED_ACTION=1
fi
@ -272,7 +264,7 @@ php_invoke()
if [ "$PHP_MAINTSCRIPT_NAME" = 'postrm' ] && [ "$PHP_MAINTSCRIPT_METHOD" = "purge" ] ; then
php_msg "debug" "php_invoke $PHP_MAINTSCRIPT_NAME: Purging state for $MOD for PHP $version $sapi sapi"
# this will return RC=1
( php$CMD -p -f -v "$version" -s "$sapi" -q "$MOD" > /dev/null 2>&1 )
( "php$CMD" -p -f -v "$version" -s "$sapi" -q "$MOD" > /dev/null 2>&1 )
else
php_msg "debug" "php_invoke $MOD $PHP_MAINTSCRIPT_NAME: No action required for PHP $version $sapi sapi"
fi
@ -284,11 +276,11 @@ php_invoke()
return 1
;;
esac
if [ -n "${PHP_NEED_ACTION:-}" -a -n "$rcd_action" ]; then
dpkg-trigger /etc/php/$version/$sapi/conf.d
if [ -n "${PHP_NEED_ACTION:-}" ]; then
dpkg-trigger "/etc/php/$version/$sapi/conf.d"
fi
done
done
}
)
# vim: syntax=sh sw=8 sts=8 sr noet