diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-12-02 20:46:48 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-12-02 20:46:48 (GMT) |
commit | b7572f08f48c4b29c137c7b62f10be9436b6efa3 (patch) | |
tree | 326485f0f49c4ab74c9d70c9a205c1dd5853c742 /Modules | |
parent | 8a10ecc051b0932a8386050675862e98db5a5691 (diff) | |
download | cpython-b7572f08f48c4b29c137c7b62f10be9436b6efa3.zip cpython-b7572f08f48c4b29c137c7b62f10be9436b6efa3.tar.gz cpython-b7572f08f48c4b29c137c7b62f10be9436b6efa3.tar.bz2 |
Merged revisions 76636 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r76636 | antoine.pitrou | 2009-12-02 21:37:54 +0100 (mer., 02 déc. 2009) | 5 lines
Issue #7333: The `posix` module gains an `initgroups()` function providing
access to the initgroups(3) C library call on Unix systems which implement
it. Patch by Jean-Paul Calderone.
........
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/posixmodule.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index eaf5b40..3ed8d5f 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -3979,6 +3979,30 @@ posix_getgroups(PyObject *self, PyObject *noargs) } #endif +#ifdef HAVE_INITGROUPS +PyDoc_STRVAR(posix_initgroups__doc__, +"initgroups(username, gid) -> None\n\n\ +Call the system initgroups() to initialize the group access list with all of\n\ +the groups of which the specified username is a member, plus the specified\n\ +group id."); + +static PyObject * +posix_initgroups(PyObject *self, PyObject *args) +{ + char *username; + long gid; + + if (!PyArg_ParseTuple(args, "sl:initgroups", &username, &gid)) + return NULL; + + if (initgroups(username, (gid_t) gid) == -1) + return PyErr_SetFromErrno(PyExc_OSError); + + Py_INCREF(Py_None); + return Py_None; +} +#endif + #ifdef HAVE_GETPGID PyDoc_STRVAR(posix_getpgid__doc__, "getpgid(pid) -> pgid\n\n\ @@ -7184,6 +7208,9 @@ static PyMethodDef posix_methods[] = { #ifdef HAVE_SETGROUPS {"setgroups", posix_setgroups, METH_O, posix_setgroups__doc__}, #endif /* HAVE_SETGROUPS */ +#ifdef HAVE_INITGROUPS + {"initgroups", posix_initgroups, METH_VARARGS, posix_initgroups__doc__}, +#endif /* HAVE_INITGROUPS */ #ifdef HAVE_GETPGID {"getpgid", posix_getpgid, METH_VARARGS, posix_getpgid__doc__}, #endif /* HAVE_GETPGID */ |