1

运行环境:

Mac OS X 10.8.3 英特尔 64 位

Python 2.7.3

如何解决 setuid 无人长度问题?

重击

$ id nobody
uid=4294967294(nobody) gid=4294967294(nobody) groups=4294967294(nobody),12(everyone),61(localaccounts)

$ cat /etc/password
nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false

Python

>>> import pwd
>>> import os
>>> uid = pwd.getpwnam('nobody')
>>> uid
pwd.struct_passwd(pw_name='nobody', pw_passwd='*', pw_uid=4294967294, pw_gid=4294967294, pw_gecos='Unprivileged User', pw_dir='/var/empty', pw_shell='/usr/bin/false')
>>> uid = pwd.getpwnam('nobody')[2]
>>> uid
4294967294
>>> os.setuid(uid)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: user id too big
4

1 回答 1

3

此问题已在 Python 2.7.4、3.2.4 和 3.3.1 中修复(请参阅http://bugs.python.org/issue4591)。

于 2013-04-12T04:34:49.820 回答