summaryrefslogtreecommitdiff
path: root/Modules/grpmodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-10 21:56:49 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-10 21:56:49 +0200
commit7cf5599346e397c3489012ad818b4f9b5d572b89 (patch)
treee3970ed7dd73a385d704121071307a05333ec054 /Modules/grpmodule.c
parentac99576a8eda27d7554c5293df22d29ec9a2043d (diff)
downloadcpython-git-7cf5599346e397c3489012ad818b4f9b5d572b89.tar.gz
Issue #4591: Uid and gid values larger than 2**31 are supported now.
Diffstat (limited to 'Modules/grpmodule.c')
-rw-r--r--Modules/grpmodule.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/Modules/grpmodule.c b/Modules/grpmodule.c
index 7dfda280c7..f85cdd46fc 100644
--- a/Modules/grpmodule.c
+++ b/Modules/grpmodule.c
@@ -2,8 +2,8 @@
/* UNIX group file access module */
#include "Python.h"
+#include "posixmodule.h"
-#include <sys/types.h>
#include <grp.h>
static PyStructSequence_Field struct_group_type_fields[] = {
@@ -69,7 +69,7 @@ mkgrent(struct group *p)
Py_INCREF(Py_None);
}
#endif
- SET(setIndex++, PyLong_FromLong((long) p->gr_gid));
+ SET(setIndex++, _PyLong_FromGid(p->gr_gid));
SET(setIndex++, w);
#undef SET
@@ -85,17 +85,24 @@ static PyObject *
grp_getgrgid(PyObject *self, PyObject *pyo_id)
{
PyObject *py_int_id;
- unsigned int gid;
+ gid_t gid;
struct group *p;
py_int_id = PyNumber_Long(pyo_id);
if (!py_int_id)
return NULL;
- gid = PyLong_AS_LONG(py_int_id);
+ if (!_Py_Gid_Converter(py_int_id, &gid)) {
+ Py_DECREF(py_int_id);
+ return NULL;
+ }
Py_DECREF(py_int_id);
if ((p = getgrgid(gid)) == NULL) {
- PyErr_Format(PyExc_KeyError, "getgrgid(): gid not found: %d", gid);
+ PyObject *gid_obj = _PyLong_FromGid(gid);
+ if (gid_obj == NULL)
+ return NULL;
+ PyErr_Format(PyExc_KeyError, "getgrgid(): gid not found: %S", gid_obj);
+ Py_DECREF(gid_obj);
return NULL;
}
return mkgrent(p);