From patchwork Sat Aug 22 01:20:07 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sh0127.shin@lge.com X-Patchwork-Id: 96038 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C1FFC5DF8C for ; Sat, 22 Aug 2026 01:20:20 +0000 (UTC) Received: from lgeamrelo11.lge.com (lgeamrelo11.lge.com [156.147.23.51]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.2777.1787361614582995285 for ; Fri, 21 Aug 2026 18:20:15 -0700 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: lge.com, ip: 156.147.23.51, mailfrom: sh0127.shin@lge.com) Received: from unknown (HELO lgeamrelo02.lge.com) (156.147.1.126) by 156.147.23.51 with ESMTP; 22 Aug 2026 10:20:12 +0900 X-Original-SENDERIP: 156.147.1.126 X-Original-MAILFROM: sh0127.shin@lge.com Received: from unknown (HELO swfarm-oeci-r122-2204..) (156.147.61.178) by 156.147.1.126 with ESMTP; 22 Aug 2026 10:20:12 +0900 X-Original-SENDERIP: 156.147.61.178 X-Original-MAILFROM: sh0127.shin@lge.com From: sh0127.shin@lge.com To: bitbake-devel@lists.openembedded.org Cc: sh0127.shin@lge.com Subject: [PATCH] fetch2: add 'fixperms' option for tar archives with restrictive permissions Date: Sat, 22 Aug 2026 01:20:07 +0000 Message-Id: <20260822012007.189830-1-sh0127.shin@lge.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sat, 22 Aug 2026 01:20:20 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/20017 From: "sh0127.shin" Some tar archives contain directories with restrictive permissions (e.g. drw-r--r--) that can prevent extraction or subsequent processing from completing successfully. Extend FetchMethod.unpack() with a new 'fixperms' SRC_URI parameter. When 'fixperms=1' is specified: 1. Add --delay-directory-restore to the tar command to defer directory permission restoration until all contents are extracted. 2. Apply chmod -R +X after extraction to ensure directories remain traversable and executable files retain appropriate execute permissions. Usage: SRC_URI = "https://example.com/foo.tgz;fixperms=1" Signed-off-by: sh0127.shin --- lib/bb/fetch2/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py index 9cb268be5..1c3bab6d7 100644 --- a/lib/bb/fetch2/__init__.py +++ b/lib/bb/fetch2/__init__.py @@ -1564,6 +1564,8 @@ class FetchMethod(object): if unpack: tar_cmd = ['tar', '--extract', '--no-same-owner'] + if 'fixperms' in urldata.parm and urldata.parm['fixperms'] == '1': + tar_cmd.append('--delay-directory-restore') if 'striplevel' in urldata.parm: striplevel = urldata.parm['striplevel'] if not striplevel.isdigit(): @@ -1659,6 +1661,9 @@ class FetchMethod(object): bb.note("Unpacking %s to %s/" % (file, unpackdir)) _run(cmd) + if 'fixperms' in urldata.parm and urldata.parm['fixperms'] == '1': + _run(['chmod', '-R', '+X', unpackdir]) + if iterate is True: iterate_urldata = urldata iterate_urldata.localpath = "%s/%s" % (rootdir, iterate_file) From patchwork Sat Aug 22 02:28:19 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sh0127.shin@lge.com X-Patchwork-Id: 96039 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AF2BC5DF8C for ; Sat, 22 Aug 2026 02:28:32 +0000 (UTC) Received: from lgeamrelo13.lge.com (lgeamrelo13.lge.com [156.147.23.53]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.16.1787365705035491483 for ; Fri, 21 Aug 2026 19:28:25 -0700 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: lge.com, ip: 156.147.23.53, mailfrom: sh0127.shin@lge.com) Received: from unknown (HELO lgeamrelo04.lge.com) (156.147.1.127) by 156.147.23.53 with ESMTP; 22 Aug 2026 11:28:22 +0900 X-Original-SENDERIP: 156.147.1.127 X-Original-MAILFROM: sh0127.shin@lge.com Received: from unknown (HELO swfarm-oeci-r122-2204..) (156.147.61.178) by 156.147.1.127 with ESMTP; 22 Aug 2026 11:28:22 +0900 X-Original-SENDERIP: 156.147.61.178 X-Original-MAILFROM: sh0127.shin@lge.com From: sh0127.shin@lge.com To: bitbake-devel@lists.openembedded.org Cc: sh0127.shin@lge.com Subject: [PATCH 2/2] fetch2/tests: add test for fixperms option Date: Sat, 22 Aug 2026 02:28:19 +0000 Message-Id: <20260822022819.194891-1-sh0127.shin@lge.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260822012007.189830-1-sh0127.shin@lge.com> References: <20260822012007.189830-1-sh0127.shin@lge.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sat, 22 Aug 2026 02:28:32 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/20018 From: "sh0127.shin" Add a unit test for the 'fixperms' SRC_URI parameter introduced in FetchMethod.unpack(). The test creates a tar.gz archive containing a directory with restrictive permissions (0o644, no execute bit), then verifies that unpacking with fixperms=1: 1. Successfully extracts files inside the restrictive directory. 2. Restores the execute bit on the directory via chmod -R +X. Signed-off-by: sh0127.shin --- lib/bb/tests/fetch.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py index a1e4b45f8..0bf6e6983 100644 --- a/lib/bb/tests/fetch.py +++ b/lib/bb/tests/fetch.py @@ -876,6 +876,37 @@ class FetcherLocalTest(FetcherTest): with self.subTest(striplevel=repr(value)): self.assertInvalidStriplevel(value) + def test_local_fixperms(self): + """Test that fixperms=1 allows extraction of archives with restrictive directory permissions""" + import tarfile + import stat + + # Create a tar archive with a directory having restrictive permissions (drw-r--r--) + archive_path = os.path.join(self.localsrcdir, 'archive_fixperms.tar.gz') + with tarfile.open(archive_path, 'w:gz') as tar: + # Add a directory with no execute bit (0o644) + dirinfo = tarfile.TarInfo(name='restrictive_dir') + dirinfo.type = tarfile.DIRTYPE + dirinfo.mode = 0o644 + tar.addfile(dirinfo) + # Add a file inside the restrictive directory + import io + content = b'test content' + fileinfo = tarfile.TarInfo(name='restrictive_dir/testfile.txt') + fileinfo.size = len(content) + fileinfo.mode = 0o644 + tar.addfile(fileinfo, io.BytesIO(content)) + + # Without fixperms, extraction may fail or leave inaccessible dirs + # With fixperms=1, chmod -R +X is applied after extraction + tree = self.fetchUnpack(['file://archive_fixperms.tar.gz;fixperms=1']) + self.assertIn('restrictive_dir/testfile.txt', tree) + + # Verify directory is traversable after fixperms + dirpath = os.path.join(self.unpackdir, 'restrictive_dir') + dirstat = os.stat(dirpath) + self.assertTrue(dirstat.st_mode & stat.S_IXUSR, "Directory should have execute bit after fixperms") + def dummyGitTest(self, suffix): # Create dummy local Git repo src_dir = tempfile.mkdtemp(dir=self.tempdir,