diff mbox series

package/dracut: fix dracut_wrapper

Message ID 20240225225728.2949216-1-romain.naour@smile.fr
State Accepted
Headers show
Series package/dracut: fix dracut_wrapper | expand

Commit Message

Romain Naour Feb. 25, 2024, 10:57 p.m. UTC
As reported by Thierry Bultel [1], dracut doesn't work since the
version bump to version 059.

Further investigation by Andreas Naumann [2] reported that the issue
come from this commit d010fa0 refactor(dracut-install): fork() instead
of popen(), sanitise line reading [3].

The issue come from our dracut_wrapper and how DRACUT_LDD is defined.
Indeed dracut expect DRACUT_LDD=ldd or a single binary (without
arguments) but we are using "prelink-rtld --root='${sysroot}'".

With the change introduced by [3], our DRACUT_LDD is used
directly by execlp() leading to an error:

  execlp(ldd, ldd, fullsrcpath, (char *)NULL);

Use mktemp to generate a temporary dracut-ldd script using
prelink-rtld --root='${sysroot}' ${1}

execute dracut.real in a subshell to cleanup the temporary file
at the end of the dracut wrapper script.

Fixes:
https://gitlab.com/buildroot.org/buildroot/-/jobs/6224243423 [tests.fs.test_cpio.TestCpioDracutGlibcMergedUsr]
https://gitlab.com/buildroot.org/buildroot/-/jobs/6224243434 [tests.fs.test_cpio.TestCpioDracutMuslMergedUsr]
https://gitlab.com/buildroot.org/buildroot/-/jobs/6224243567 [tests.fs.test_cpio.TestCpioDracutUclibcMergedUsr]
https://gitlab.com/buildroot.org/buildroot/-/jobs/6224243559 [tests.fs.test_cpio.TestCpioDracutGlibc]
https://gitlab.com/buildroot.org/buildroot/-/jobs/6224243504 [tests.fs.test_cpio.TestCpioDracutUclibc]
https://gitlab.com/buildroot.org/buildroot/-/jobs/6224243498 [tests.fs.test_cpio.TestCpioDracutMusl]

[1] http://lists.busybox.net/pipermail/buildroot/2024-February/684145.html
[2] http://lists.busybox.net/pipermail/buildroot/2024-February/684503.html
[3] https://github.com/dracutdevs/dracut/commit/d010fa0d7f8ef42ad31729d027d2e4be6dd6e588

Fixes: 145f01ded5 ("package/dracut: bump to version 059")
Reported-by: Thierry Bultel <thierry.bultel@linatsea.fr>
Signed-off-by: Romain Naour <romain.naour@smile.fr>
---
 package/dracut/dracut_wrapper | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Peter Korsgaard March 1, 2024, 6:23 p.m. UTC | #1
>>>>> "Romain" == Romain Naour <romain.naour@smile.fr> writes:

 > As reported by Thierry Bultel [1], dracut doesn't work since the
 > version bump to version 059.

 > Further investigation by Andreas Naumann [2] reported that the issue
 > come from this commit d010fa0 refactor(dracut-install): fork() instead
 > of popen(), sanitise line reading [3].

 > The issue come from our dracut_wrapper and how DRACUT_LDD is defined.
 > Indeed dracut expect DRACUT_LDD=ldd or a single binary (without
 > arguments) but we are using "prelink-rtld --root='${sysroot}'".

 > With the change introduced by [3], our DRACUT_LDD is used
 > directly by execlp() leading to an error:

 >   execlp(ldd, ldd, fullsrcpath, (char *)NULL);

 > Use mktemp to generate a temporary dracut-ldd script using
 > prelink-rtld --root='${sysroot}' ${1}

 > execute dracut.real in a subshell to cleanup the temporary file
 > at the end of the dracut wrapper script.

 > Fixes:
 > https://gitlab.com/buildroot.org/buildroot/-/jobs/6224243423 [tests.fs.test_cpio.TestCpioDracutGlibcMergedUsr]
 > https://gitlab.com/buildroot.org/buildroot/-/jobs/6224243434 [tests.fs.test_cpio.TestCpioDracutMuslMergedUsr]
 > https://gitlab.com/buildroot.org/buildroot/-/jobs/6224243567 [tests.fs.test_cpio.TestCpioDracutUclibcMergedUsr]
 > https://gitlab.com/buildroot.org/buildroot/-/jobs/6224243559 [tests.fs.test_cpio.TestCpioDracutGlibc]
 > https://gitlab.com/buildroot.org/buildroot/-/jobs/6224243504 [tests.fs.test_cpio.TestCpioDracutUclibc]
 > https://gitlab.com/buildroot.org/buildroot/-/jobs/6224243498 [tests.fs.test_cpio.TestCpioDracutMusl]

 > [1] http://lists.busybox.net/pipermail/buildroot/2024-February/684145.html
 > [2] http://lists.busybox.net/pipermail/buildroot/2024-February/684503.html
 > [3] https://github.com/dracutdevs/dracut/commit/d010fa0d7f8ef42ad31729d027d2e4be6dd6e588

 > Fixes: 145f01ded5 ("package/dracut: bump to version 059")
 > Reported-by: Thierry Bultel <thierry.bultel@linatsea.fr>
 > Signed-off-by: Romain Naour <romain.naour@smile.fr>
 > ---
 >  package/dracut/dracut_wrapper | 14 ++++++++++++--
 >  1 file changed, 12 insertions(+), 2 deletions(-)

 > diff --git a/package/dracut/dracut_wrapper b/package/dracut/dracut_wrapper
 > index 0464db17fe..889322d1c6 100644
 > --- a/package/dracut/dracut_wrapper
 > +++ b/package/dracut/dracut_wrapper
 > @@ -31,8 +31,18 @@ if [ -z "${sysroot}" ]; then
 >  fi
 
 >  topdir="$(dirname "$(realpath "$(dirname "${0}")")")"
 > -export DRACUT_LDD="${topdir}/sbin/prelink-rtld --root='${sysroot}'"
 > +DRACUT_LDD="$(mktemp /tmp/dracut-ldd.XXXXXX)"
 > +cat >"${DRACUT_LDD}" <<EOL
 > +#!/bin/bash
 > +${topdir}/sbin/prelink-rtld --root='${sysroot}' \${1}
 > +EOL
 > +chmod +x ${DRACUT_LDD}

Here shellcheck complains:

In package/dracut/dracut_wrapper line 39:
chmod +x ${DRACUT_LDD}
         ^-----------^ SC2086 (info): Double quote to prevent globbing and word splitting.

So I've quoted it and committed, thanks.
Peter Korsgaard March 18, 2024, 1:30 p.m. UTC | #2
>>>>> "Romain" == Romain Naour <romain.naour@smile.fr> writes:

 > As reported by Thierry Bultel [1], dracut doesn't work since the
 > version bump to version 059.

 > Further investigation by Andreas Naumann [2] reported that the issue
 > come from this commit d010fa0 refactor(dracut-install): fork() instead
 > of popen(), sanitise line reading [3].

 > The issue come from our dracut_wrapper and how DRACUT_LDD is defined.
 > Indeed dracut expect DRACUT_LDD=ldd or a single binary (without
 > arguments) but we are using "prelink-rtld --root='${sysroot}'".

 > With the change introduced by [3], our DRACUT_LDD is used
 > directly by execlp() leading to an error:

 >   execlp(ldd, ldd, fullsrcpath, (char *)NULL);

 > Use mktemp to generate a temporary dracut-ldd script using
 > prelink-rtld --root='${sysroot}' ${1}

 > execute dracut.real in a subshell to cleanup the temporary file
 > at the end of the dracut wrapper script.

 > Fixes:
 > https://gitlab.com/buildroot.org/buildroot/-/jobs/6224243423 [tests.fs.test_cpio.TestCpioDracutGlibcMergedUsr]
 > https://gitlab.com/buildroot.org/buildroot/-/jobs/6224243434 [tests.fs.test_cpio.TestCpioDracutMuslMergedUsr]
 > https://gitlab.com/buildroot.org/buildroot/-/jobs/6224243567 [tests.fs.test_cpio.TestCpioDracutUclibcMergedUsr]
 > https://gitlab.com/buildroot.org/buildroot/-/jobs/6224243559 [tests.fs.test_cpio.TestCpioDracutGlibc]
 > https://gitlab.com/buildroot.org/buildroot/-/jobs/6224243504 [tests.fs.test_cpio.TestCpioDracutUclibc]
 > https://gitlab.com/buildroot.org/buildroot/-/jobs/6224243498 [tests.fs.test_cpio.TestCpioDracutMusl]

 > [1] http://lists.busybox.net/pipermail/buildroot/2024-February/684145.html
 > [2] http://lists.busybox.net/pipermail/buildroot/2024-February/684503.html
 > [3] https://github.com/dracutdevs/dracut/commit/d010fa0d7f8ef42ad31729d027d2e4be6dd6e588

 > Fixes: 145f01ded5 ("package/dracut: bump to version 059")
 > Reported-by: Thierry Bultel <thierry.bultel@linatsea.fr>
 > Signed-off-by: Romain Naour <romain.naour@smile.fr>

Committed to 2023.11.x, thanks.
diff mbox series

Patch

diff --git a/package/dracut/dracut_wrapper b/package/dracut/dracut_wrapper
index 0464db17fe..889322d1c6 100644
--- a/package/dracut/dracut_wrapper
+++ b/package/dracut/dracut_wrapper
@@ -31,8 +31,18 @@  if [ -z "${sysroot}" ]; then
 fi
 
 topdir="$(dirname "$(realpath "$(dirname "${0}")")")"
-export DRACUT_LDD="${topdir}/sbin/prelink-rtld --root='${sysroot}'"
+DRACUT_LDD="$(mktemp /tmp/dracut-ldd.XXXXXX)"
+cat >"${DRACUT_LDD}" <<EOL
+#!/bin/bash
+${topdir}/sbin/prelink-rtld --root='${sysroot}' \${1}
+EOL
+chmod +x ${DRACUT_LDD}
+export DRACUT_LDD
 export DRACUT_INSTALL="${topdir}/lib/dracut/dracut-install"
 export DRACUT_LDCONFIG=/bin/true
 export dracutbasedir="${topdir}/lib/dracut"
-exec "${topdir}/bin/dracut.real" "${@}"
+(exec "${topdir}/bin/dracut.real" "${@}")
+
+if [ -n "${DRACUT_LDD}" ]; then
+	rm -f "${DRACUT_LDD}"
+fi