[issue1747858] chown broken on 64bit

Sean Reifschneider report at bugs.python.org
Wed Jan 16 09:37:16 CET 2008


Sean Reifschneider added the comment:

I've reviewed the chown system call under Linux and I think the included
patch will resolve the problem.  With that patch on a Fedora 8 64-bit
system I'm getting:

>>> os.stat('/tmp/foo')
posix.stat_result(st_mode=33188, st_ino=5111823, st_dev=64769L,
st_nlink=1, st_uid=0, st_gid=0, st_size=0, st_atime=1200469633,
st_mtime=1200469633, st_ctime=1200469657)
>>> os.chown('/tmp/foo', 4294967294, -1)
>>> os.stat('/tmp/foo')
posix.stat_result(st_mode=33188, st_ino=5111823, st_dev=64769L,
st_nlink=1, st_uid=4294967294, st_gid=0, st_size=0, st_atime=1200469633,
st_mtime=1200469633, st_ctime=1200469683)
>>> 

However, it's unclear to me whether there are any platforms that might
define uid_t as signed, and if so whether this code would do the right
thing on those platforms.

I don't know of a way to do it in C off hand, but perhaps we could check
the exact type of the uid_t and gid_t types and see if they're signed or
unsigned and use that combined with sizeof(uid_t) to use exactly the
correct ParseTuple format string.

I've attached a patch that dynamically tries to figure out the size to
use.  Does this seem overly-heavy?  If it seems appropriate, the same
would need to be applied to the other chown functions.

Added file: http://bugs.python.org/file9182/posixmodule-chown-dynamic.patch

_____________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1747858>
_____________________________________


More information about the Python-bugs-list mailing list