proposal: add setresuid() system call to python

Diez B. Roggisch deets at nospam.web.de
Mon Jul 20 15:10:17 CEST 2009


Neal Becker wrote:


again with his notorious gmane.comp.python.general group that doesn't work
for any decent news-reader.....


> Mahmoud Abdelkader wrote:
> 
>> Why don't you write a python extension module? This is a perfect
>> opportunity for that.
>> 
> I think having a module just for one system call is a bit silly.  Why not
> add to os module?

While I do agree that it's an omission, it is easy enough to get it yourself
using ctypes:


from ctypes import *
from ctypes.util import find_library

clib = CDLL(find_library("c"))
# this might be different on 64bit
__uid_t = c_uint

_setresuid = clib.setresuid
_setresuid.argtypes = [__uid_t, __uid_t, __uid_t]
_setresuid.restype = c_int

def setresuid(ruid, euid, suid):
    return _setresuid(__uid_t(ruid), __uid_t(euid), __uid_t(suid))


print setresuid(1000, 1000, 1000) # returns 0 for me
print setresuid(1001, 1001, 1001) # fails.

Diez



More information about the Python-list mailing list