@@ -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,