summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Orlitzky <mjo@gentoo.org>2023-07-25 17:26:57 -0400
committerMichael Orlitzky <mjo@gentoo.org>2023-07-25 18:11:35 -0400
commit104abf95fed7fb8bb0d1078627beaa32ae23013a (patch)
tree8c29cc47ea47c16e109975bba2ca4ea9d0947ffc
parentBump version to 0.9.8 (diff)
downloadeselect-php-104abf95fed7fb8bb0d1078627beaa32ae23013a.tar.gz
eselect-php-104abf95fed7fb8bb0d1078627beaa32ae23013a.tar.bz2
eselect-php-104abf95fed7fb8bb0d1078627beaa32ae23013a.zip
openrc/init.d/php-fpm.in.in: don't run eselect during sysinit.
OpenRC caches its dependency tree at boot time, before any non-boot services have started. It does this by sourcing service scripts, which means that running commands in global scope is dangerous because they may not be available yet. In bug 910589 we witness this with a call to eselect in the php-fpm service script, which in turn runs realpath, and can fail: /usr/bin/eselect line 65 /dev/fd/63 No such file or directory /usr/share/eselect/libs/path-manipulations.bash: line 66 realpath : No such file or directory Since there are no dependencies for the php-fpm service, and since no other parts of the service script are cached at that time (source: prayer), the error is harmless. This commit essentially hides it: we now check if the RC_RUNLEVEL is "sysinit" and skip the PHP_SLOT computation if it is. Signed-off-by: Michael Orlitzky <mjo@gentoo.org> Bug: https://bugs.gentoo.org/910589
-rw-r--r--openrc/init.d/php-fpm.in.in18
1 files changed, 15 insertions, 3 deletions
diff --git a/openrc/init.d/php-fpm.in.in b/openrc/init.d/php-fpm.in.in
index 3e67e3c..79300b6 100644
--- a/openrc/init.d/php-fpm.in.in
+++ b/openrc/init.d/php-fpm.in.in
@@ -17,9 +17,21 @@
#
PHP_SLOT="${SVCNAME#php-fpm-}"
-if [ "${PHP_SLOT}" = "php-fpm" ] ; then
- # Getting the saved slot allows for clean stops when upgrading to a new slot
- # This will initially be empty on start and fall through to the default
+
+# OpenRC caches service dependencies at boot time (in the sysinit
+# runlevel), before any non-boot services are started. If we try to
+# run eselect then, it can fail, producing a scary error message (bug
+# 910589). For now, the error message is harmless, but we may be
+# relying on an implementation detail to make that claim: it's
+# important that no other parts of this script are cached when its
+# dependencies are. Nevertheless -- for now at least -- we can avoid
+# the error message by skipping the call to eselect in the sysinit
+# runlevel, because our (empty) depend() function does not use
+# PHP_SLOT in any way.
+if [ "${PHP_SLOT}" = "php-fpm" ] && [ "${RC_RUNLEVEL}" != "sysinit" ]; then
+ # Getting the saved slot allows for clean stops when upgrading to
+ # a new slot This will initially be empty on start and fall
+ # through to the default
PHP_SLOT="$(service_get_value PHP_SLOT)"
if [ -z "${PHP_SLOT}" ]; then
PHP_SLOT="$(eselect php show fpm)"