diff options
author | Lars Gustäbel <lars@gustaebel.de> | 2011-09-05 14:58:14 (GMT) |
---|---|---|
committer | Lars Gustäbel <lars@gustaebel.de> | 2011-09-05 14:58:14 (GMT) |
commit | 2e7ddd374b48649b34db6f86313379080de24280 (patch) | |
tree | d2776b6b18344bc443e94624510854f1f3e9d394 /Lib/tarfile.py | |
parent | d9e0b068af175a2fc1c2fe979ab97b5d4f8239b7 (diff) | |
download | cpython-2e7ddd374b48649b34db6f86313379080de24280.zip cpython-2e7ddd374b48649b34db6f86313379080de24280.tar.gz cpython-2e7ddd374b48649b34db6f86313379080de24280.tar.bz2 |
Issue #12841: Fix tarfile extraction of non-existent uids/gids.
tarfile unnecessarily checked the existence of numerical user and group ids on
extraction. If one of them did not exist the respective id of the current user
(i.e. root) was used for the file and ownership information was lost. (Patch
by Sebastien Luttringer)
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r-- | Lib/tarfile.py | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 3d52a81..1ece716 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -2368,17 +2368,11 @@ class TarFile(object): try: g = grp.getgrnam(tarinfo.gname)[2] except KeyError: - try: - g = grp.getgrgid(tarinfo.gid)[2] - except KeyError: - g = os.getgid() + g = tarinfo.gid try: u = pwd.getpwnam(tarinfo.uname)[2] except KeyError: - try: - u = pwd.getpwuid(tarinfo.uid)[2] - except KeyError: - u = os.getuid() + u = tarinfo.uid try: if tarinfo.issym() and hasattr(os, "lchown"): os.lchown(targetpath, u, g) |