Title: TarFile.chown: should use TarInfo.uid if user lookup fails
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.2, Python 3.3, Python 2.7
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: lars.gustaebel Nosy List: doughellmann, eric.araujo, lars.gustaebel, mgold, mgold-qnx
Priority: low Keywords:

Created on 2011-04-19 16:03 by mgold-qnx, last changed 2011-09-02 08:57 by lars.gustaebel. This issue is now closed.

Messages (4)
msg134074 - (view) Author: Michael Gold (mgold-qnx) Date: 2011-04-19 16:03
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.
msg134273 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-04-22 16:54
If you make the suggested change to your Python, do the tests still pass?
msg134301 - (view) Author: Michael Gold (mgold) Date: 2011-04-23 13:45
The tests passed on Linux (with Python 3.2 under fakeroot):
Ran 240 tests in 9.613s

But I don't see any tests that check the uid/gid of extracted files.
msg143390 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2011-09-02 08:57
Issue #12841 is a duplicate of this one, but I give it precedence because it comes with a working patch.
Date User Action Args
2011-09-02 08:57:36lars.gustaebelsetstatus: open -> closed
resolution: duplicate
messages: + msg143390

versions: + Python 2.7, Python 3.3
2011-09-01 20:02:50doughellmannsetnosy: + doughellmann
2011-04-23 13:45:50mgoldsetnosy: + mgold
messages: + msg134301
2011-04-22 16:54:39eric.araujosetnosy: + eric.araujo
messages: + msg134273
2011-04-22 11:09:57lars.gustaebelsetpriority: normal -> low
assignee: lars.gustaebel
2011-04-20 19:58:15ned.deilysetnosy: + lars.gustaebel
2011-04-19 16:03:35mgold-qnxcreate