[New-bugs-announce] [issue11879] TarFile.chown: should use TarInfo.uid if user lookup fails
Michael Gold
report at bugs.python.org
Tue Apr 19 18:03:35 CEST 2011
New submission from Michael Gold <mgold at qnx.com>:
In TarFile.chown, if the lookup
u = pwd.getpwnam(tarinfo.uname)[2]
fails, this line is used:
u = pwd.getpwuid(tarinfo.uid)[2]
This will fail if the uid isn't in /etc/passwd. I think "u = tarinfo.uid" would make more sense. This fallback could also be used if the pwd module isn't present or tarinfo.uname isn't filled. Here's a code sample:
u = tarinfo.uid
if tarinfo.uname and pwd:
try: u = pwd.getpwnam(tarinfo.uname)[2]
except KeyError: pass
The same issue applies to group lookup.
----------
components: Library (Lib)
messages: 134074
nosy: mgold-qnx
priority: normal
severity: normal
status: open
title: TarFile.chown: should use TarInfo.uid if user lookup fails
type: behavior
versions: Python 3.2
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11879>
_______________________________________
More information about the New-bugs-announce
mailing list