diff options
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r-- | Lib/tarfile.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index b184ed8..b789cca 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -2005,15 +2005,11 @@ class TarFile(object): for tarinfo in members: if tarinfo.isdir(): - # Extract directory with a safe mode, so that - # all files below can be extracted as well. - try: - os.makedirs(os.path.join(path, tarinfo.name), 0o700) - except EnvironmentError: - pass + # Extract directories with a safe mode. directories.append(tarinfo) - else: - self.extract(tarinfo, path) + tarinfo = copy.copy(tarinfo) + tarinfo.mode = 0o700 + self.extract(tarinfo, path) # Reverse sort directories. directories.sort(key=lambda a: a.name) @@ -2118,6 +2114,8 @@ class TarFile(object): # Create all upper directories. upperdirs = os.path.dirname(targetpath) if upperdirs and not os.path.exists(upperdirs): + # Create directories that are not part of the archive with + # default permissions. os.makedirs(upperdirs) if tarinfo.islnk() or tarinfo.issym(): @@ -2154,7 +2152,9 @@ class TarFile(object): """Make a directory called targetpath. """ try: - os.mkdir(targetpath) + # Use a safe mode for the directory, the real mode is set + # later in _extract_member(). + os.mkdir(targetpath, 0o700) except EnvironmentError as e: if e.errno != errno.EEXIST: raise |