Index: Modules/posixmodule.c =================================================================== --- Modules/posixmodule.c (revision 78265) +++ Modules/posixmodule.c (working copy) @@ -3829,6 +3829,9 @@ "getgroups() -> list of group IDs\n\n\ Return list of supplemental group IDs for the process."); +#include +int getgrouplist_2(const char *name, gid_t basegid, gid_t **groups); + static PyObject * posix_getgroups(PyObject *self, PyObject *noargs) { @@ -3840,13 +3843,20 @@ /* defined to be 16 on Solaris7, so this should be a small number */ #define MAX_GROUPS 64 #endif - gid_t grouplist[MAX_GROUPS]; + gid_t *grouplist = NULL; + struct passwd *pw; int n; - n = getgroups(MAX_GROUPS, grouplist); - if (n < 0) + if ((pw = getpwuid(getuid())) == NULL) { + errno = EINVAL; posix_error(); - else { + return NULL; + } + n = getgrouplist_2(pw->pw_name, pw->pw_gid, &grouplist); + if (n < 0) { + errno = EINVAL; + posix_error(); + } else { result = PyList_New(n); if (result != NULL) { int i; @@ -3862,6 +3872,7 @@ } } + if (grouplist) free(grouplist); return result; } #endif @@ -5713,15 +5724,15 @@ posix_setgroups(PyObject *self, PyObject *groups) { int i, len; - gid_t grouplist[MAX_GROUPS]; + gid_t *grouplist; if (!PySequence_Check(groups)) { PyErr_SetString(PyExc_TypeError, "setgroups argument must be a sequence"); return NULL; } len = PySequence_Size(groups); - if (len > MAX_GROUPS) { - PyErr_SetString(PyExc_ValueError, "too many groups"); + if ((grouplist = (gid_t *)malloc(len * sizeof(gid_t))) == NULL) { + PyErr_NoMemory(); return NULL; } for(i = 0; i < len; i++) { @@ -5767,6 +5778,7 @@ if (setgroups(len, grouplist) < 0) return posix_error(); + free(grouplist); Py_INCREF(Py_None); return Py_None; } @@ -7538,6 +7550,15 @@ #ifdef _MIPS_CS_VENDOR {"MIPS_CS_VENDOR", _MIPS_CS_VENDOR}, #endif +#ifdef _CS_DARWIN_USER_DIR + {"CS_DARWIN_USER_DIR", _CS_DARWIN_USER_DIR}, +#endif +#ifdef _CS_DARWIN_USER_TEMP_DIR + {"CS_DARWIN_USER_TEMP_DIR", _CS_DARWIN_USER_TEMP_DIR}, +#endif +#ifdef _CS_DARWIN_USER_CACHE_DIR + {"CS_DARWIN_USER_CACHE_DIR", _CS_DARWIN_USER_CACHE_DIR}, +#endif }; static int