[Python-checkins] cpython (2.7): Issue #12841: Fix tarfile extraction of non-existent uids/gids.
lars.gustaebel
python-checkins at python.org
Mon Sep 5 17:14:44 CEST 2011
http://hg.python.org/cpython/rev/b64ef2951093
changeset: 72274:b64ef2951093
branch: 2.7
parent: 72209:af09b9d9be93
user: Lars Gustäbel <lars at gustaebel.de>
date: Mon Sep 05 17:04:18 2011 +0200
summary:
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)
files:
Lib/tarfile.py | 10 ++--------
Misc/NEWS | 5 +++++
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -2264,17 +2264,11 @@
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)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -40,6 +40,11 @@
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.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list