Commit d44bfee3 authored by Lars Gustäbel's avatar Lars Gustäbel

Issue #1507247, #2004: Use mode 0700 for temporary directories and

default permissions for missing directories.

(backport from r53526, r60588)
parent 681a2150
...@@ -1509,15 +1509,11 @@ class TarFile(object): ...@@ -1509,15 +1509,11 @@ class TarFile(object):
for tarinfo in members: for tarinfo in members:
if tarinfo.isdir(): if tarinfo.isdir():
# Extract directory with a safe mode, so that # Extract directories with a safe mode.
# all files below can be extracted as well.
try:
os.makedirs(os.path.join(path, tarinfo.name), 0777)
except EnvironmentError:
pass
directories.append(tarinfo) directories.append(tarinfo)
else: tarinfo = copy.copy(tarinfo)
self.extract(tarinfo, path) tarinfo.mode = 0700
self.extract(tarinfo, path)
# Reverse sort directories. # Reverse sort directories.
directories.sort(lambda a, b: cmp(a.name, b.name)) directories.sort(lambda a, b: cmp(a.name, b.name))
...@@ -1622,19 +1618,9 @@ class TarFile(object): ...@@ -1622,19 +1618,9 @@ class TarFile(object):
# Create all upper directories. # Create all upper directories.
upperdirs = os.path.dirname(targetpath) upperdirs = os.path.dirname(targetpath)
if upperdirs and not os.path.exists(upperdirs): if upperdirs and not os.path.exists(upperdirs):
ti = TarInfo() # Create directories that are not part of the archive with
ti.name = upperdirs # default permissions.
ti.type = DIRTYPE os.makedirs(upperdirs)
ti.mode = 0777
ti.mtime = tarinfo.mtime
ti.uid = tarinfo.uid
ti.gid = tarinfo.gid
ti.uname = tarinfo.uname
ti.gname = tarinfo.gname
try:
self._extract_member(ti, ti.name)
except:
pass
if tarinfo.islnk() or tarinfo.issym(): if tarinfo.islnk() or tarinfo.issym():
self._dbg(1, "%s -> %s" % (tarinfo.name, tarinfo.linkname)) self._dbg(1, "%s -> %s" % (tarinfo.name, tarinfo.linkname))
...@@ -1670,7 +1656,9 @@ class TarFile(object): ...@@ -1670,7 +1656,9 @@ class TarFile(object):
"""Make a directory called targetpath. """Make a directory called targetpath.
""" """
try: try:
os.mkdir(targetpath) # Use a safe mode for the directory, the real mode is set
# later in _extract_member().
os.mkdir(targetpath, 0700)
except EnvironmentError, e: except EnvironmentError, e:
if e.errno != errno.EEXIST: if e.errno != errno.EEXIST:
raise raise
......
...@@ -80,6 +80,9 @@ Core and builtins ...@@ -80,6 +80,9 @@ Core and builtins
Library Library
------- -------
- #1507247, #2004: tarfile.py: Use mode 0700 for temporary directories and
default permissions for missing directories.
- #175006: The debugger used to skip the condition of a "while" statement - #175006: The debugger used to skip the condition of a "while" statement
after the first iteration. Now it correctly steps on the expression, and after the first iteration. Now it correctly steps on the expression, and
breakpoints on the "while" statement are honored on each loop. breakpoints on the "while" statement are honored on each loop.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment