diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2010-03-01 05:43:43 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2010-03-01 05:43:43 (GMT) |
commit | 6a65f85e79db20f16a7f18873322984f5b1333ee (patch) | |
tree | d53e74421ac7c76f66770054dea7834b25ae7339 /Modules | |
parent | 3c699d334a1f6f413326bd8a3cbcd1a7a4b4a93d (diff) | |
download | cpython-6a65f85e79db20f16a7f18873322984f5b1333ee.zip cpython-6a65f85e79db20f16a7f18873322984f5b1333ee.tar.gz cpython-6a65f85e79db20f16a7f18873322984f5b1333ee.tar.bz2 |
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.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 26c6e46..f729e88 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5650,9 +5650,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; } @@ -5677,9 +5684,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; } |