Skip to content

Commit d1a36d3

Browse files
Dzejroudanimo
authored andcommitted
fix(install): handle $LIB in ldd output parsing
The ldd output can contain the variable $LIB, which is a documented feature of ldd. In a previous commit [0], dracut-install received support for this variable, but that was later reverted [1] due to issues [2][3] on Gentoo ARM64. The part before '=>' does not necessarily refer to an existing file (e.g. due to the usage of $LIB) and thus [1] could be seen as a regression to anyone that uses this ldd feature. This PR combines both cases together and whenever it find a '$' character (i.e. a variable) on the left side of the '=>' symbol, it uses the right hand path (and thus uses evaluation done by ldd), otherwise falls back to the behavior set by [1]. Reproducer that was presented to me: $ grep "ibz.so" /etc/ld.so.preload || cat << EOF >> /etc/ld.so.preload /\$LIB/libz.so.1.2.11 EOF $ mkdir -p /var/tmp/dracut.xitk6p/initramfs $ strace /usr/lib/dracut/dracut-install -D /var/tmp/dracut.xitk6p/initramfs -l /bin/bash 2>&1|grep ibz $ rm -rf /var/tmp/dracut.xitk6p/ [0] 45404a2 [1] 6d886bb [2] #471 [3] https://bugs.gentoo.org/667752
1 parent 3697891 commit d1a36d3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/install/dracut-install.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,15 @@ static int resolve_deps(const char *src)
589589
if (strstr(buf, destrootdir))
590590
break;
591591

592-
p = strchr(buf, '/');
592+
p = buf;
593+
if (strchr(p, '$')) {
594+
/* take ldd variable expansion into account */
595+
p = strstr(p, "=>");
596+
if (!p)
597+
p = buf;
598+
}
599+
p = strchr(p, '/');
600+
593601
if (p) {
594602
char *q;
595603

0 commit comments

Comments
 (0)