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