mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
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)
This commit is contained in:
parent
d9e0b068af
commit
2e7ddd374b
2 changed files with 7 additions and 8 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue