summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2010-03-01 05:56:53 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2010-03-01 05:56:53 (GMT)
commit18ac2b4a7178983ca97b4d29c68ed3aa1cb22a58 (patch)
tree36034266ef54d78e638a5f807f514a3439d69886 /Modules
parent807e98e0afde0441349d9e627391a88e9f6fb9db (diff)
downloadcpython-18ac2b4a7178983ca97b4d29c68ed3aa1cb22a58.zip
cpython-18ac2b4a7178983ca97b4d29c68ed3aa1cb22a58.tar.gz
cpython-18ac2b4a7178983ca97b4d29c68ed3aa1cb22a58.tar.bz2
Merged revisions 78548 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r78548 | gregory.p.smith | 2010-02-28 21:54:14 -0800 (Sun, 28 Feb 2010) | 10 lines Merged revisions 78546 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78546 | gregory.p.smith | 2010-02-28 21:43:43 -0800 (Sun, 28 Feb 2010) | 3 lines Fixes issue #7999: os.setreuid() and os.setregid() would refuse to accept a -1 parameter on some platforms such as OS X. ........ ................
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 814c9ba..502bf62 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -4370,9 +4370,16 @@ posix_setreuid (PyObject *self, PyObject *args)
uid_t ruid, euid;
if (!PyArg_ParseTuple(args, "ll", &ruid_arg, &euid_arg))
return NULL;
- ruid = ruid_arg;
- euid = euid_arg;
- if (euid != euid_arg || ruid != ruid_arg) {
+ if (ruid_arg == -1)
+ ruid = (uid_t)-1; /* let the compiler choose how -1 fits */
+ else
+ ruid = ruid_arg; /* otherwise, assign from our long */
+ if (euid_arg == -1)
+ euid = (uid_t)-1;
+ else
+ euid = euid_arg;
+ if ((euid_arg != -1 && euid != euid_arg) ||
+ (ruid_arg != -1 && ruid != ruid_arg)) {
PyErr_SetString(PyExc_OverflowError, "user id too big");
return NULL;
}
@@ -4397,9 +4404,16 @@ posix_setregid (PyObject *self, PyObject *args)
gid_t rgid, egid;
if (!PyArg_ParseTuple(args, "ll", &rgid_arg, &egid_arg))
return NULL;
- rgid = rgid_arg;
- egid = egid_arg;
- if (egid != egid_arg || rgid != rgid_arg) {
+ if (rgid_arg == -1)
+ rgid = (gid_t)-1; /* let the compiler choose how -1 fits */
+ else
+ rgid = rgid_arg; /* otherwise, assign from our long */
+ if (egid_arg == -1)
+ egid = (gid_t)-1;
+ else
+ egid = egid_arg;
+ if ((egid_arg != -1 && egid != egid_arg) ||
+ (rgid_arg != -1 && rgid != rgid_arg)) {
PyErr_SetString(PyExc_OverflowError, "group id too big");
return NULL;
}