[issue12800] 'tarfile.StreamError: seeking backwards is not allowed' when extract symlink

2011-08-20 Thread Aurélien Dunand

New submission from Aurélien Dunand :

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 
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.

--
components: Library (Lib)
messages: 142580
nosy: adunand
priority: normal
severity: normal
status: open
title: 'tarfile.StreamError: seeking backwards is not allowed' when extract 
symlink
type: behavior
versions: Python 3.2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12800] 'tarfile.StreamError: seeking backwards is not allowed' when extract symlink

2011-08-20 Thread Ned Deily

Changes by Ned Deily :


--
nosy: +lars.gustaebel

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12800] 'tarfile.StreamError: seeking backwards is not allowed' when extract symlink

2011-09-12 Thread Lars Gustäbel

Changes by Lars Gustäbel :


--
assignee:  -> lars.gustaebel

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com