Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Lib/test/test_tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2593,6 +2593,30 @@ def test_keyword_only(self, mock_geteuid):
tarfl.extract, filename_1, TEMPDIR, False, True)


# Enable this test when Issue 30438 is fixed
@unittest.skip
class ExtractTarredReadonlyDirectoryTest(unittest.TestCase):

def test_extract_tarred_readonly_directory(self):
"Issue 30438: tarring, then extracting, a read-only directory with a file should succeed"

read_only_dir_name = os.path.join(TEMPDIR, 'read_only_dir')
file_name = os.path.join(read_only_dir_name, 'sample.txt')
tarfile_name = os.path.join(TEMPDIR, 'sample.tar')

os.makedirs(read_only_dir_name)
with open(file_name, 'w') as outfile:
outfile.write('')

os.chmod(read_only_dir_name, 0o555) # Read and Execute permissions
os.chmod(file_name, 0o444) # Read Only permission
with tarfile.open(tarfile_name, "w") as tarfl:
tarfl.add(read_only_dir_name)
tarfl.add(file_name)

tarfile.open(tarfile_name).extractall()


def setUpModule():
support.unlink(TEMPDIR)
os.makedirs(TEMPDIR)
Expand Down