OverflowError:用户ID太大

时间:2013-04-12 04:05:20

标签: python linux macos

运行时环境:

Mac OS X 10.8.3 Intel 64bit

Python 2.7.3

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

的bash

$ 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

>>> 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

1 个答案:

答案 0 :(得分:3)

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