]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #12841: Fix tarfile extraction of non-existent uids/gids.
authorLars Gustäbel <lars@gustaebel.de>
Mon, 5 Sep 2011 14:58:14 +0000 (16:58 +0200)
committerLars Gustäbel <lars@gustaebel.de>
Mon, 5 Sep 2011 14:58:14 +0000 (16:58 +0200)
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)

Lib/tarfile.py
Misc/NEWS

index 3d52a81b9e1b8793f3f97c16831ce2d93057ffc0..1ece716197761f6785f4b68caff3742925407508 100644 (file)
@@ -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)
index ff1a0add421870bd3d04e9a75a17c1464db78868..bd8c49788b305da73c1880036e48ea1dc8bb0965 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -73,6 +73,11 @@ Core and Builtins
 Library
 -------
 
+- Issue #12841: 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.
+
 - Issue #10946: The distutils commands bdist_dumb, bdist_wininst and bdist_msi
   now respect a --skip-build option given to bdist.