运行环境:
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