Issue 11879: TarFile.chown: should use TarInfo.uid if user lookup fails (original) (raw)

Created on 2011-04-19 16:03 by mgold-qnx, last changed 2022-04-11 14:57 by admin. 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 OK 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.
History
Date User Action Args
2022-04-11 14:57:16 admin set github: 56088
2011-09-02 08:57:36 lars.gustaebel set status: open -> closedresolution: duplicatemessages: + versions: + Python 2.7, Python 3.3
2011-09-01 20:02:50 doughellmann set nosy: + doughellmann
2011-04-23 13:45:50 mgold set nosy: + mgoldmessages: +
2011-04-22 16:54:39 eric.araujo set nosy: + eric.araujomessages: +
2011-04-22 11:09:57 lars.gustaebel set priority: normal -> lowassignee: lars.gustaebel
2011-04-20 19:58:15 ned.deily set nosy: + lars.gustaebel
2011-04-19 16:03:35 mgold-qnx create