Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 666246

Summary: sys-libs/musl ldconfig does not respect -r/$ROOT
Product: Gentoo Linux Reporter: Vic Kerr (wikky) <wikky>
Component: Current packagesAssignee: Anthony Basile <blueness>
Status: RESOLVED FIXED    
Severity: normal CC: jstein, lu_zero, musl, sam, toolchain, wikky
Priority: Normal Keywords: PATCH, PullRequest
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://github.com/gentoo/gentoo/pull/22984
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Proposed fix

Description Vic Kerr (wikky) 2018-09-14 20:46:04 UTC
Created attachment 546966 [details, diff]
Proposed fix

emerge --root=/foo calls ldconfig -r -X /foo. However, the ldconfig script bundled with the ebuild ignores the argument.

When running emerge as user this manifests in most emerges asking:

mv: replace '/etc/ld-musl-x86_64.path', overriding mode 0644 (rw-r--r--)?

When running as root, it is even worse as the file in / is silently overwritten and the file in /foo is never created.

Attached proposed patch that fixes the issue.
Comment 1 Vic Kerr (wikky) 2018-09-14 20:51:20 UTC
>emerge --root=/foo calls ldconfig -r -X /foo.

Of course I meant ldconfig -X -r /foo.
Comment 2 Anthony Basile gentoo-dev 2018-09-26 12:11:13 UTC
(In reply to Wiktor Kerr from comment #1)
> >emerge --root=/foo calls ldconfig -r -X /foo.
> 
> Of course I meant ldconfig -X -r /foo.

i haven't had a chance to look at this, but i assume you've tested emerging both with and without --root=/foo  I don't want to commit this and break existing systems.  the patch seems correct but i'd like confirmation that it works in both cases.
Comment 3 Anthony Basile gentoo-dev 2018-09-26 12:13:47 UTC
(In reply to Anthony Basile from comment #2)
> (In reply to Wiktor Kerr from comment #1)
> > >emerge --root=/foo calls ldconfig -r -X /foo.
> > 
> > Of course I meant ldconfig -X -r /foo.
> 
> i haven't had a chance to look at this, but i assume you've tested emerging
> both with and without --root=/foo  I don't want to commit this and break
> existing systems.  the patch seems correct but i'd like confirmation that it
> works in both cases.

like here's the kind of thing i'm concerned about.  there is a sanity check near the top:

LDSO_CONF="/etc/ld.so.conf"
if [[ ! -e $LDSO_CONF ]]; then
	echo "$LDSO_CONF not found" >&2
	exit 1
fi


this will only check the current root's ld.so.conf, not $ROOT/ld.so.conf.
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-11-10 07:54:00 UTC
Oh boo, I think I just hit this. I was getting horrifying errors about being unable to find libgcc* but running ldconfig within the chroot helped.
Comment 5 Larry the Git Cow gentoo-dev 2021-11-19 03:03:08 UTC
The bug has been referenced in the following commit(s):

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

commit bd2656625bf0ed0b05e5b6de9ead4a73f09c58fe
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2021-11-18 00:45:48 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2021-11-19 03:02:40 +0000

    sys-libs/musl: additional ROOT fixes for ldconfig
    
    Move around some declarations so we get sensible default
    values but only perform the sanity checks _after_ we
    parse command line arguments to take into account e.g.
    -r (root).
    
    Bug: https://bugs.gentoo.org/666246
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-libs/musl/files/ldconfig.in-r1 |  17 ++--
 sys-libs/musl/musl-1.2.2-r5.ebuild | 167 +++++++++++++++++++++++++++++++++++++
 sys-libs/musl/musl-9999.ebuild     |   2 +-
 3 files changed, 177 insertions(+), 9 deletions(-)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9d41e6bdaff27bd16fbd33f46406f77e9074ae78

commit 9d41e6bdaff27bd16fbd33f46406f77e9074ae78
Author:     Wiktor Kerr <w@kerr.sh>
AuthorDate: 2021-11-18 00:43:49 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2021-11-19 03:02:31 +0000

    sys-libs/musl: make ldconfig script respect -r
    
    Bug: https://bugs.gentoo.org/666246
    Signed-off-by: Wiktor Kerr <w@kerr.sh>
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-libs/musl/files/ldconfig.in-r1 | 146 +++++++++++++++++++++++++++++++++++++
 1 file changed, 146 insertions(+)
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-11-19 03:19:19 UTC
Thanks both. This seems to work fine for me so far.
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-11-22 12:11:46 UTC
This is being used in stages too without issue.