[issue30438] tarfile would fail to extract tarballs with files under R/O directories

Yaroslav Halchenko report at bugs.python.org
Wed May 24 08:48:49 EDT 2017


Yaroslav Halchenko added the comment:

Dear Catherine,

Thank you very much for looking into it!! And sorry that I have missed the fact of recursive addition when pointing to a directory.  Indeed though, tar handles that case a bit more gracefully.

BUT I feel somewhat dumb since I am afraid that may be the actual original issue I have observed was simply because I already had that archive extracted and tried to extract it twice, overriding existing files.  That leads to the failure I think I was trying to chase down (example with a sample tiny real annex repo):

$> wget -q http://onerussian.com/tmp/sample.tar ; python -c 'import tarfile; tarfile.open("sample.tar").extractall()'                                
$> python -c 'import tarfile; tarfile.open("sample.tar").extractall()'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/tarfile.py", line 2081, in extractall
    self.extract(tarinfo, path)
  File "/usr/lib/python2.7/tarfile.py", line 2118, in extract
    self._extract_member(tarinfo, os.path.join(path, tarinfo.name))
  File "/usr/lib/python2.7/tarfile.py", line 2194, in _extract_member
    self.makefile(tarinfo, targetpath)
  File "/usr/lib/python2.7/tarfile.py", line 2234, in makefile
    with bltn_open(targetpath, "wb") as target:
IOError: [Errno 13] Permission denied: './sample/.git/annex/objects/G6/qW/SHA256E-s4--181210f8f9c779c26da1d9b2075bde0127302ee0e3fca38c9a83f5b1dd8e5d3b/SHA256E-s4--181210f8f9c779c26da1d9b2075bde0127302ee0e3fca38c9a83f5b1dd8e5d3b'

$> tar -xf sample.tar && echo "extracted ok"
extracted ok


But I wouldn't even consider it a failure but would take it as a feature in my case (stuff is read-only for a reason!)

Altogether, I do not have the earth-shaking problem now, thus if you feel that issue needs retitle or closing, feel free to do so

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30438>
_______________________________________


More information about the Python-bugs-list mailing list