summaryrefslogtreecommitdiffstats
path: root/Modules/pwdmodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-10 20:03:08 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-10 20:03:08 (GMT)
commitc2d020090b324285bf144f29ac4da3771be7c40a (patch)
tree83b61e08fea50d104d75a7c12e64909e6ea82c50 /Modules/pwdmodule.c
parentd80b16dbd5cc817c452df4a114134b63977551c4 (diff)
parent7cf5599346e397c3489012ad818b4f9b5d572b89 (diff)
downloadcpython-c2d020090b324285bf144f29ac4da3771be7c40a.zip
cpython-c2d020090b324285bf144f29ac4da3771be7c40a.tar.gz
cpython-c2d020090b324285bf144f29ac4da3771be7c40a.tar.bz2
Issue #4591: Uid and gid values larger than 2**31 are supported now.
Diffstat (limited to 'Modules/pwdmodule.c')
-rw-r--r--Modules/pwdmodule.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c
index d1045af..4807aa3 100644
--- a/Modules/pwdmodule.c
+++ b/Modules/pwdmodule.c
@@ -2,8 +2,8 @@
/* UNIX password file access module */
#include "Python.h"
+#include "posixmodule.h"
-#include <sys/types.h>
#include <pwd.h>
static PyStructSequence_Field struct_pwd_type_fields[] = {
@@ -74,8 +74,8 @@ mkpwent(struct passwd *p)
#else
SETS(setIndex++, p->pw_passwd);
#endif
- SETI(setIndex++, p->pw_uid);
- SETI(setIndex++, p->pw_gid);
+ PyStructSequence_SET_ITEM(v, setIndex++, _PyLong_FromUid(p->pw_uid));
+ PyStructSequence_SET_ITEM(v, setIndex++, _PyLong_FromGid(p->pw_gid));
#ifdef __VMS
SETS(setIndex++, "");
#else
@@ -104,13 +104,17 @@ See help(pwd) for more on password database entries.");
static PyObject *
pwd_getpwuid(PyObject *self, PyObject *args)
{
- unsigned int uid;
+ uid_t uid;
struct passwd *p;
- if (!PyArg_ParseTuple(args, "I:getpwuid", &uid))
+ if (!PyArg_ParseTuple(args, "O&:getpwuid", _Py_Uid_Converter, &uid))
return NULL;
if ((p = getpwuid(uid)) == NULL) {
+ PyObject *uid_obj = _PyLong_FromUid(uid);
+ if (uid_obj == NULL)
+ return NULL;
PyErr_Format(PyExc_KeyError,
- "getpwuid(): uid not found: %d", uid);
+ "getpwuid(): uid not found: %S", uid_obj);
+ Py_DECREF(uid_obj);
return NULL;
}
return mkpwent(p);