Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 910589 - app-eselect/eselect-php: openrc script calls external commands (eselect) in global scope (was: sys-apps/openrc-0.47.1 /usr/bin/eselect line 65 /dev/fd/63 No such file or directory)
Summary: app-eselect/eselect-php: openrc script calls external commands (eselect) in g...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: PHP Bugs
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2023-07-20 12:48 UTC by David Duchesne
Modified: 2023-07-27 03:04 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
0001-openrc-init.d-php-fpm.in.in-don-t-run-eselect-during.patch (0001-openrc-init.d-php-fpm.in.in-don-t-run-eselect-during.patch,2.58 KB, patch)
2023-07-25 22:14 UTC, Michael Orlitzky
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Duchesne 2023-07-20 12:48:19 UTC
Hi,
After upgrading to openrc-0.47.1, this line is showing up on boot below *Caching service dependencies*

/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

I'm not sure if it is related specifically to 0.47.1 since the same "error" message is present when downgrading to 0.46. It happened very recently though. (I boot up my machine every day)

Any idea ?
Regards

Reproducible: Always
Comment 1 Ionen Wolkens gentoo-dev 2023-07-20 13:06:52 UTC
>/usr/bin/eselect line 65 /dev/fd/63 No such file or directory
would happen if eselect is used before /proc is mounted, possible(?) some openrc script you have installed is using it in depend() which sounds a bit dodgy

in other words I think this can be considered a bug for that script rather than openrc

>/usr/share/eselect/libs/path-manipulations.bash: line 66 realpath : No such file or directory
realpath is not in /bin if you were using a /usr on a separate partition, again likely caused by depend() being made to use eselect too early

it may also be missing if using some embedded setup without coreutils, albeit it's getting officially added to POSIX last I know of
Comment 2 Ionen Wolkens gentoo-dev 2023-07-20 13:09:50 UTC
(In reply to Ionen Wolkens from comment #1)
> >/usr/share/eselect/libs/path-manipulations.bash: line 66 realpath : No such file or directory
> realpath is not in /bin if you were using a /usr on a separate partition,
> again likely caused by depend() being made to use eselect too early
oh wait, nevermind that bit -- given the former didn't work (/dev/fd bit is used to adjust PATH), I guess PATH is mangled
Comment 3 Ionen Wolkens gentoo-dev 2023-07-20 13:11:09 UTC
(In reply to Ionen Wolkens from comment #2)
> oh wait, nevermind that bit -- given the former didn't work (/dev/fd bit is
> used to adjust PATH), I guess PATH is mangled
eselect did make recent change in that regard, albeit I don't think it really supports being used without /proc in the first place
Comment 4 Ionen Wolkens gentoo-dev 2023-07-20 13:33:29 UTC
anyhow, `grep -r eselect /etc/init.d /etc/conf.d` should tell us what is using eselect on your system, assuming it's not being indirectly used through another command
Comment 5 David Duchesne 2023-07-20 14:12:25 UTC
Thanks Ionen!

I think it is related to php-fpm then (installed recently to try the new rutorrent ebuild)

grep -r eselect /etc/init.d /etc/conf.d
/etc/init.d/php-fpm:# whatever the currently-eselected fpm implementation is. In that
/etc/init.d/php-fpm:# actual slot by querying eselect.
/etc/init.d/php-fpm:# slot php7.1 eselected, but also a php-fpm-php7.1 init script. Should
/etc/init.d/php-fpm:        PHP_SLOT="$(eselect php show fpm)"

eselect php show php-fpm
!!! Error: Please choose one of the following modules: cli apache2 fpm cgi phpdbg

I forgot to configure it. For now, I can't reboot right now but I'll give an update later.
Comment 6 Ionen Wolkens gentoo-dev 2023-07-20 14:30:19 UTC
Yep, that explains it then.

I thought it'd be depend(), but global scope would cause the same issue. There's no guarantee the system is ready to use any external commands while calculating dependencies or sourcing the script to accomplish that.

The script is from eselect-php:
https://gitweb.gentoo.org/proj/eselect-php.git/tree/openrc/init.d/php-fpm.in.in?id=1c6a7ab#n25

Fortunately I don't believe this is harmful beside being noisy. So it can be safely ignored until this is fixed.
Comment 7 David Duchesne 2023-07-21 08:46:49 UTC
After :
eselect php set fpm php8.1

the error message still appears at boot.
Otherwise, php-fpm starts fine.

If dev-lang/php is not installed then the message no longers shows up (obviously)
Thanks ionen for the hint!
Comment 8 Michael Orlitzky gentoo-dev 2023-07-21 13:18:54 UTC
Sorry, we've known that this is a mess for a while. There's some discussion on bug #761319 about how to fix it. Basically, we need to throw out the eselect magic and make slotted php-fpm work like slotted postgresql, with one init script per slot.

It may be possible to hide the error in the meantime though. I'll think about it and try to hack something together.
Comment 9 Michael Orlitzky gentoo-dev 2023-07-25 22:14:38 UTC
Created attachment 866283 [details, diff]
0001-openrc-init.d-php-fpm.in.in-don-t-run-eselect-during.patch

Can you try this patch to make sure it solves your problem? I've already edited the src/dst filenames so that you can apply it in /etc/init.d with -p1.

If it works for you, I'll release a new version of eselect-php with the fix.
Comment 10 David Duchesne 2023-07-26 13:55:47 UTC
(In reply to Michael Orlitzky from comment #9)
> Created attachment 866283 [details, diff] [details, diff]
> 0001-openrc-init.d-php-fpm.in.in-don-t-run-eselect-during.patch
> 
> Can you try this patch to make sure it solves your problem? I've already
> edited the src/dst filenames so that you can apply it in /etc/init.d with
> -p1.
> 
> If it works for you, I'll release a new version of eselect-php with the fix.

Hello, tested and working 100%. Cheers!
Comment 11 Larry the Git Cow gentoo-dev 2023-07-26 22:53:48 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=104abf95fed7fb8bb0d1078627beaa32ae23013a

commit 104abf95fed7fb8bb0d1078627beaa32ae23013a
Author:     Michael Orlitzky <mjo@gentoo.org>
AuthorDate: 2023-07-25 21:26:57 +0000
Commit:     Michael Orlitzky <mjo@gentoo.org>
CommitDate: 2023-07-25 22:11:35 +0000

    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

 openrc/init.d/php-fpm.in.in | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
Comment 12 Larry the Git Cow gentoo-dev 2023-07-27 03:04:09 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=49ab2317e4577179b8a2655479dd43d4dbd1d02c

commit 49ab2317e4577179b8a2655479dd43d4dbd1d02c
Author:     Michael Orlitzky <mjo@gentoo.org>
AuthorDate: 2023-07-27 02:58:33 +0000
Commit:     Michael Orlitzky <mjo@gentoo.org>
CommitDate: 2023-07-27 03:00:32 +0000

    app-eselect/eselect-php: add 0.9.9
    
    Closes: https://bugs.gentoo.org/910589
    Signed-off-by: Michael Orlitzky <mjo@gentoo.org>

 app-eselect/eselect-php/Manifest                 |  1 +
 app-eselect/eselect-php/eselect-php-0.9.9.ebuild | 39 ++++++++++++++++++++++++
 2 files changed, 40 insertions(+)