From: Victor Stinner Date: Sun, 15 Aug 2010 09:22:44 +0000 (+0000) Subject: Issue #9604: posix.initgroups() encodes the username using the fileystem X-Git-Tag: v3.2a2~304 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=61ec5dca2bf66d43fd196f771b27464e75e8b41a;p=thirdparty%2FPython%2Fcpython.git Issue #9604: posix.initgroups() encodes the username using the fileystem encoding and surrogateescape error handler. Patch written by David Watson. --- diff --git a/Misc/NEWS b/Misc/NEWS index f5cfd3844216..a322b3df1612 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -83,6 +83,9 @@ Extensions Library ------- +- Issue #9604: posix.initgroups() encodes the username using the fileystem + encoding and surrogateescape error handler. Patch written by David Watson. + - Issue #9603: posix.ttyname() and posix.ctermid() decode the terminal name using the filesystem encoding and surrogateescape error handler. Patch written by David Watson. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index df7cb832579e..71512896ecd7 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -4249,13 +4249,19 @@ group id."); static PyObject * posix_initgroups(PyObject *self, PyObject *args) { + PyObject *oname; char *username; + int res; long gid; - if (!PyArg_ParseTuple(args, "sl:initgroups", &username, &gid)) + if (!PyArg_ParseTuple(args, "O&l:initgroups", + PyUnicode_FSConverter, &oname, &gid)) return NULL; + username = PyBytes_AS_STRING(oname); - if (initgroups(username, (gid_t) gid) == -1) + res = initgroups(username, (gid_t) gid); + Py_DECREF(oname); + if (res == -1) return PyErr_SetFromErrno(PyExc_OSError); Py_INCREF(Py_None);