mirror of
https://git.yoctoproject.org/poky
synced 2026-06-21 22:53:48 +02:00
Python 3.14 added security checks around archive extraction, and by default will refuse to handle symlinks with absolute paths. It's possible to handle this using 'filter' argument, but it is not always available in older Python versions on various host distributions we need to support, so let's extract only the needed files directly using tarfile module. busybox is itself a symlink to busybox.nosuid, so both are extracted. [YOCTO #16195] (From OE-Core rev: 799e2124cdcb27bd924598619da61cbd11730b56) Signed-off-by: Alexander Kanavin <alex@linutronix.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit d52d00a3bb4a1ba93e88f1d24d8bb99d6aa321eb) Signed-off-by: Yoann Congal <yoann.congal@smile.fr> Signed-off-by: Paul Barker <paul@pbarker.dev>
48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
#
|
|
# Copyright OpenEmbedded Contributors
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
import os
|
|
import subprocess
|
|
import tempfile
|
|
import tarfile
|
|
|
|
from oeqa.selftest.case import OESelftestTestCase
|
|
from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars, runCmd
|
|
|
|
|
|
class Minidebuginfo(OESelftestTestCase):
|
|
def test_minidebuginfo(self):
|
|
target_sys = get_bb_var("TARGET_SYS")
|
|
binutils = "binutils-cross-{}".format(get_bb_var("TARGET_ARCH"))
|
|
|
|
image = 'core-image-minimal'
|
|
bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME', 'READELF'], image)
|
|
|
|
self.write_config("""
|
|
DISTRO_FEATURES:append = " minidebuginfo"
|
|
IMAGE_FSTYPES = "tar.bz2"
|
|
""")
|
|
bitbake("{} {}:do_addto_recipe_sysroot".format(image, binutils))
|
|
|
|
native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", binutils)
|
|
|
|
# confirm that executables and shared libraries contain an ELF section
|
|
# ".gnu_debugdata" which stores minidebuginfo.
|
|
with tempfile.TemporaryDirectory(prefix = "unpackfs-") as unpackedfs:
|
|
filename = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], "{}.tar.bz2".format(bb_vars['IMAGE_LINK_NAME']))
|
|
with tarfile.open(filename) as tar:
|
|
tar.extract("./bin/busybox", path=unpackedfs)
|
|
tar.extract("./bin/busybox.nosuid", path=unpackedfs)
|
|
tar.extract("./lib/libc.so.6", path=unpackedfs)
|
|
|
|
r = runCmd([bb_vars['READELF'], "-W", "-S", os.path.join(unpackedfs, "bin", "busybox")],
|
|
native_sysroot = native_sysroot, target_sys = target_sys)
|
|
self.assertIn(".gnu_debugdata", r.output)
|
|
|
|
r = runCmd([bb_vars['READELF'], "-W", "-S", os.path.join(unpackedfs, "lib", "libc.so.6")],
|
|
native_sysroot = native_sysroot, target_sys = target_sys)
|
|
self.assertIn(".gnu_debugdata", r.output)
|
|
|