This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Scott.Leerssen
Recipients Scott.Leerssen, lars.gustaebel, orsenthil, santoso.wijaya, srid
Date 2011-04-27.12:24:41
SpamBayes Score 8.2191036e-05
Marked as misclassified No
Message-id <1303907082.34.0.851657990451.issue10761@psf.upfronthosting.co.za>
In-reply-to
Content
It happens on RedHat and CentOS 5, but I suspect it would happen on any Unix variant.  Here's a test that exacerbates the issue:


#
# test_tarfile.py
#
# Description:
#       tests for python tarfile module
#
# $Id$
#

import os
import shutil
import tarfile
import tempfile

def test_tar_overwrites_symlink():
    d = tempfile.mkdtemp()
    try:
        new_dir_name = os.path.join(d, 'newdir')
        archive_name = os.path.join(d, 'newdir.tar')
        os.mkdir(new_dir_name)
        source_file_name = os.path.join(new_dir_name, 'source')
        target_link_name = os.path.join(new_dir_name, 'symlink')
        with open(source_file_name, 'w') as f:
            f.write('something\n')
        os.symlink(source_file_name, target_link_name)
        with tarfile.open(archive_name, 'w') as tar:
            for f in [source_file_name, target_link_name]:
                tar.add(f, arcname=os.path.basename(f))
        # this should not raise OSError: [Errno 17] File exists
        with tarfile.open(archive_name, 'r') as tar:
            tar.extractall(path=new_dir_name)
    finally:
        shutil.rmtree(d)
History
Date User Action Args
2011-04-27 12:24:42Scott.Leerssensetrecipients: + Scott.Leerssen, lars.gustaebel, orsenthil, srid, santoso.wijaya
2011-04-27 12:24:42Scott.Leerssensetmessageid: <1303907082.34.0.851657990451.issue10761@psf.upfronthosting.co.za>
2011-04-27 12:24:41Scott.Leerssenlinkissue10761 messages
2011-04-27 12:24:41Scott.Leerssencreate