Skip to content

Commit

Permalink
Issue python#12841: Fix tarfile extraction of non-existent uids/gids.
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
gustaebel committed Sep 5, 2011
1 parent cbce2c0 commit 8babfdf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 2 additions & 8 deletions Lib/tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2264,17 +2264,11 @@ def chown(self, tarinfo, targetpath):
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)
Expand Down
5 changes: 5 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,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.

Expand Down

0 comments on commit 8babfdf

Please sign in to comment.