summaryrefslogtreecommitdiffstats
path: root/Modules/pwdmodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-10 19:56:49 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-10 19:56:49 (GMT)
commit7cf5599346e397c3489012ad818b4f9b5d572b89 (patch)
treee3970ed7dd73a385d704121071307a05333ec054 /Modules/pwdmodule.c
parentac99576a8eda27d7554c5293df22d29ec9a2043d (diff)
downloadcpython-7cf5599346e397c3489012ad818b4f9b5d572b89.zip
cpython-7cf5599346e397c3489012ad818b4f9b5d572b89.tar.gz
cpython-7cf5599346e397c3489012ad818b4f9b5d572b89.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 1e0903a..632ffe3 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);