diff -ur Python-2.6.1.orig/configure.in Python-2.6.1-res/configure.in --- Python-2.6.1.orig/configure.in 2008-11-16 02:02:56.000000000 -0600 +++ Python-2.6.1-res/configure.in 2009-09-16 16:13:56.148979072 -0500 @@ -2448,12 +2448,13 @@ AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \ clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ - getpriority getpwent getspnam getspent getsid getwd \ + getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \ kill killpg lchmod lchown lstat mkfifo mknod mktime \ mremap nice pathconf pause plock poll pthread_init \ putenv readlink realpath \ select setegid seteuid setgid \ - setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \ + setlocale setregid setreuid setresuid setresgid \ + setsid setpgid setpgrp setuid setvbuf snprintf \ sigaction siginterrupt sigrelse strftime \ sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty) diff -ur Python-2.6.1.orig/Modules/posixmodule.c Python-2.6.1-res/Modules/posixmodule.c --- Python-2.6.1.orig/Modules/posixmodule.c 2008-10-09 13:06:58.000000000 -0500 +++ Python-2.6.1-res/Modules/posixmodule.c 2009-09-16 16:20:31.614544286 -0500 @@ -8301,6 +8301,88 @@ } #endif +#ifdef HAVE_SETRESUID +PyDoc_STRVAR(posix_setresuid__doc__, +"setresuid(ruid, euid, suid)\n\n\ +Set the current process's real, effective, and saved user ids."); + +static PyObject* +posix_setresuid (PyObject *self, PyObject *args) +{ + int ruid, euid, suid; + if (!PyArg_ParseTuple(args, "iii", &ruid, &euid, &suid)) { + return NULL; + } else if (setresuid(ruid, euid, suid) < 0) { + return posix_error(); + } else { + Py_INCREF(Py_None); + return Py_None; + } +} +#endif + +#ifdef HAVE_SETRESGID +PyDoc_STRVAR(posix_setresgid__doc__, +"setresgid(rgid, egid, sgid)\n\n\ +Set the current process's real, effective, and saved group ids."); + +static PyObject* +posix_setresgid (PyObject *self, PyObject *args) +{ + int rgid, egid, sgid; + if (!PyArg_ParseTuple(args, "iii", &rgid, &egid, &sgid)) { + return NULL; + } else if (setresgid(rgid, egid, sgid) < 0) { + return posix_error(); + } else { + Py_INCREF(Py_None); + return Py_None; + } +} +#endif + +#ifdef HAVE_GETRESUID +PyDoc_STRVAR(posix_getresuid__doc__, +"getresuid() -> (ruid, euid, sgid)\n\n\ +Get tuple of the current process's real, effective, and saved user ids."); + +static PyObject* +posix_getresuid (PyObject *self, PyObject *noargs) +{ + int ruid, euid, suid; + n = getresuid(&ruid, &euid, &suid); + if (n < 0) + posix_error(); + } else { + return PyTuple_Pack(3, + PyInt_FromLong((long)ruid), + PyInt_FromLong((long)euid), + PyInt_FromLong((long)suid)); + } +} +#endif + +#ifdef HAVE_GETRESGID +PyDoc_STRVAR(posix_getresgid__doc__, +"getresgid() -> (rgid, egid, sgid)\n\n\ +Get tuple of the current process's real, effective, and saved user ids."); + +static PyObject* +posix_getresgid (PyObject *self, PyObject *noargs) +{ + int rgid, egid, sgid; + n = getresgid(&rgid, &egid, &sgid); + if (n < 0) + posix_error(); + } else { + return PyTuple_Pack(3, + PyInt_FromLong((long)rgid), + PyInt_FromLong((long)egid), + PyInt_FromLong((long)sgid)); + } +} +#endif + static PyMethodDef posix_methods[] = { {"access", posix_access, METH_VARARGS, posix_access__doc__}, #ifdef HAVE_TTYNAME @@ -8611,6 +8693,19 @@ #ifdef __VMS {"urandom", vms_urandom, METH_VARARGS, vms_urandom__doc__}, #endif +#ifdef HAVE_SETRESUID + {"setresuid", posix_setresuid, METH_VARARGS, posix_setresuid__doc__), +#endif +#ifdef HAVE_SETRESGID + {"setresgid", posix_setresgid, METH_VARARGS, posix_setresgid__doc__), +#endif +#ifdef HAVE_GETRESUID + {"getresuid", posix_getresuid, METH_VARARGS, posix_getresuid__doc__), +#endif +#ifdef HAVE_GETRESGID + {"getresgid", posix_getresgid, METH_VARARGS, posix_getresgid__doc__), +#endif + {NULL, NULL} /* Sentinel */ };