Message142580
When you extractall a tarball containing a symlink in stream mode ('r|'), an Exception happens:
Traceback (most recent call last):
File "./test_extractall_stream_symlink.py", line 26, in <module>
tar.extractall(path=destdir)
File "/usr/lib/python3.2/tarfile.py", line 2134, in extractall
self.extract(tarinfo, path, set_attrs=not tarinfo.isdir())
File "/usr/lib/python3.2/tarfile.py", line 2173, in extract
set_attrs=set_attrs)
File "/usr/lib/python3.2/tarfile.py", line 2249, in _extract_member
self.makefile(tarinfo, targetpath)
File "/usr/lib/python3.2/tarfile.py", line 2289, in makefile
source.seek(tarinfo.offset_data)
File "/usr/lib/python3.2/tarfile.py", line 553, in seek
raise StreamError("seeking backwards is not allowed")
tarfile.StreamError: seeking backwards is not allowed
You can reproduce the bug with this snippet of code:
TEMPDIR='/tmp/pyton_test'
os.mkdir(TEMPDIR)
tempdir = os.path.join(TEMPDIR, "testsymlinks")
temparchive = os.path.join(TEMPDIR, "testsymlinks.tar")
destdir = os.path.join(TEMPDIR, "extract")
os.mkdir(tempdir)
try:
source_file = os.path.join(tempdir,'source')
target_file = os.path.join(tempdir,'symlink')
with open(source_file,'w') as f:
f.write('something\n')
os.symlink('source', target_file)
tar = tarfile.open(temparchive,'w')
tar.add(target_file, arcname=os.path.basename(target_file))
tar.add(source_file, arcname=os.path.basename(source_file))
tar.close()
fo = open(temparchive, 'rb')
tar = tarfile.open(fileobj=fo, mode='r|')
try:
tar.extractall(path=destdir)
finally:
tar.close()
finally:
os.unlink(temparchive)
shutil.rmtree(TEMPDIR)
If source_file is added before target_file, there is no Exception raised. But it still raised when you create the same tarball with GNU tar. |
|
Date |
User |
Action |
Args |
2011-08-20 22:57:40 | adunand | set | recipients:
+ adunand |
2011-08-20 22:57:40 | adunand | set | messageid: <1313881060.54.0.449889075101.issue12800@psf.upfronthosting.co.za> |
2011-08-20 22:57:39 | adunand | link | issue12800 messages |
2011-08-20 22:57:39 | adunand | create | |
|