From: Alexander Kanavin <alex.kanavin@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Alexander Kanavin <alex@linutronix.de>
Subject: [PATCH] selftest/minidebuginfo: extract files from tar archive using tarfile module
Date: Fri, 20 Mar 2026 14:46:58 +0100 [thread overview]
Message-ID: <20260320134658.3037500-1-alex.kanavin@gmail.com> (raw)
From: Alexander Kanavin <alex@linutronix.de>
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]
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
meta/lib/oeqa/selftest/cases/minidebuginfo.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/meta/lib/oeqa/selftest/cases/minidebuginfo.py b/meta/lib/oeqa/selftest/cases/minidebuginfo.py
index a8923460f9..5f37522c32 100644
--- a/meta/lib/oeqa/selftest/cases/minidebuginfo.py
+++ b/meta/lib/oeqa/selftest/cases/minidebuginfo.py
@@ -6,7 +6,7 @@
import os
import subprocess
import tempfile
-import shutil
+import tarfile
from oeqa.core.decorator import OETestTag
from oeqa.selftest.case import OESelftestTestCase
@@ -33,7 +33,10 @@ IMAGE_FSTYPES = "tar.bz2"
# ".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']))
- shutil.unpack_archive(filename, unpackedfs)
+ 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)
--
2.47.3
reply other threads:[~2026-03-20 13:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260320134658.3037500-1-alex.kanavin@gmail.com \
--to=alex.kanavin@gmail.com \
--cc=alex@linutronix.de \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox