summaryrefslogtreecommitdiff
path: root/dev-python/pypam
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /dev-python/pypam
reinit the tree, so we can have metadata
Diffstat (limited to 'dev-python/pypam')
-rw-r--r--dev-python/pypam/Manifest11
-rw-r--r--dev-python/pypam/files/PyPAM-0.5.0-dealloc.patch17
-rw-r--r--dev-python/pypam/files/PyPAM-0.5.0-memory-errors.patch128
-rw-r--r--dev-python/pypam/files/PyPAM-0.5.0-nofree.patch60
-rw-r--r--dev-python/pypam/files/PyPAM-0.5.0-return-value.patch57
-rw-r--r--dev-python/pypam/files/PyPAM-python3-support.patch198
-rw-r--r--dev-python/pypam/files/pypam-0.5.0-stricter.patch15
-rw-r--r--dev-python/pypam/metadata.xml8
-rw-r--r--dev-python/pypam/pypam-0.5.0-r3.ebuild46
9 files changed, 540 insertions, 0 deletions
diff --git a/dev-python/pypam/Manifest b/dev-python/pypam/Manifest
new file mode 100644
index 000000000000..316c3166a46b
--- /dev/null
+++ b/dev-python/pypam/Manifest
@@ -0,0 +1,11 @@
+AUX PyPAM-0.5.0-dealloc.patch 607 SHA256 5d73ad2efb9b5f0507c1968aa69bcc36d3981e5c02117215982abbb6825863de SHA512 105573489be31763ed01bab02ccaf7147c73b196d85d8318eceda145e86fb5c3fa3a59b7baee9d85f6d5ae40df0335689267650461f5440a9c2991954c367e8e WHIRLPOOL b0527a6c81f9fc4bea9bf5d2a3fcabdc67e9d8b4e7d5e6668949201b53e85f825260cb61152b558ec8a2f473249807687d8667272eb81f03f0caf325bff72fb3
+AUX PyPAM-0.5.0-memory-errors.patch 3708 SHA256 e500628d9ccae7c953967a70a97b3af94c5f6c52849b6615b0d1270789a1d08a SHA512 358e57ba6450b533cbdb39f559813767799e387937a610b15e5e8e78d59b6501785c40c3ffdc5b1914ff6c9220716cdf9b537847373379eb94094f6ffe23c7f5 WHIRLPOOL ba0f6d33eacc9e812baa7089cf24bb6e548ac54e35024a7637c7e756f050c6a92421ecc18c93f97490feb8e62cc68e23c1e49d84a9a0c46615c8755a25be13d5
+AUX PyPAM-0.5.0-nofree.patch 1913 SHA256 ed2964fbc2c0d8b23961cf3a9b5b77d8c4609de54ef0e557ecb64664497f8ff9 SHA512 7292483d60f75d577055f4bf7380b110620669a19b3e2e3a4700e2c816758af865213cf19b329260338e82f9a0cba03a14dea06ba636251f1436ec0c3373f751 WHIRLPOOL e02e958acccaf508497cc87c5abc08398b03a8ddf8d504ecb4da2a63e4f963939b45915273e777ec5ef7d32ac58ffb2a5cfdfcb6dfeacc0a3908269222f137f2
+AUX PyPAM-0.5.0-return-value.patch 1854 SHA256 8a5a7292b415b053a69ccb36f7cd5dfd367f273b0ca8cf1f1bcec96f05769b3e SHA512 73d81d9a7398933011eba0739e3bce7651c3da1bf38f77b510172e26f569d329c3b28e5192a25ee0616875ddad52e67697dabe021d31cc5e51e9e78941333c8d WHIRLPOOL 6bb079b5824a8cd2c2df728f82645ef3ba625c6b0899b57d85eb2f77a677e5647233ce987d2f74c0d1fb55693fd16384acb4c52ce2abba5da26f74045edd9a9f
+AUX PyPAM-python3-support.patch 5987 SHA256 1d81a8c8610c91ddfa8b86be2cfeb0adf2e64e09b89dd084d980054167fc6425 SHA512 8437e5648f4bfe7a4895324c4277e91b5588271ed31a7fa374a4d7f03af18b8f6038c90afe79f16c96219debb10d9dfb6f33883dc097edb2c67714d893acf13a WHIRLPOOL 02e1d61c60e7367913deb226fa7d9070b6ce06a1852c4b66e237034f747704ccdabe5c8ef9d99aab2b51ee13c6a33cff9c409bf5414bf5cf69cc85e474e38f5c
+AUX pypam-0.5.0-stricter.patch 335 SHA256 c6a389f7346a237501b58fa3a0ba9618616a03f506c7df262ad55cc9a5207939 SHA512 6cb56d4610fab8f14af83d64215de24b38c820c61099054c0c02bcc831b0f50dee5746def85e2ae669b8657dce2fe31fcc93f07a93e3b49f0c7a78f48acd74c7 WHIRLPOOL 13fb94ed652c8b7a0a19c951c6ab88fc0df72a3e1e6005b1c1cc92e4d89d02554985680dafcdc762c17260fe4ee88357104f43fc9fcb946611d280519e2fff93
+DIST PyPAM-0.5.0.tar.gz 105206 SHA256 796ac019b9ee805696d0d277d8fb912fa2391b6ac070dc6f9f1a9a0fadbc3a5a SHA512 9e0e919e34930d2283307cd6665c5287c664a76a5de56367bd975867ac26b376ae03d30cb3bc4a16390c977ca2690cfd2e90ac73dcc7886b8c999444da4a07e0 WHIRLPOOL 03e93e671dd4c74252b5c04ea74d389408934ce03206ec47d3dbbb2c19d4dce7b4271765d0967dbbee2c288bc3c6451b1295bf46ba82ed3665711bdc1aa173c4
+EBUILD pypam-0.5.0-r3.ebuild 1037 SHA256 3420f3a97c8749b5ef949887e290a8ee8e83ae478f6702168528403b745bc47e SHA512 9faaeabd4c6797ee5e59ea1d501ee83f1438df9ee81b961a819dc05b083b12bb8fcfd11d57d9f6ff4b2157ce65f4193ca78814a6b156c0e1c04b1f6e0a8fe1cf WHIRLPOOL ce361c5a69a2e65030e5f48cb7bb466ddbeccebd98e8a7b0a469916f09d5f9bccc88e054d20fc1bc1d17ccc72412acc3057129e3b2c9d1c467084b6f3a851113
+MISC ChangeLog 2781 SHA256 b8aa1d2e319902793da11a1f60a6d245080ce6a335da4afb032d97107e181b75 SHA512 6f58268bf721b0ec6a5cec9657b46f2f8a013b78a6f2474c556f4a0669be6c24f808e3d4428a544b4d28f69083f968bfd0b80b270a3b810c2ce0865478271c27 WHIRLPOOL 13dd583b3752c48d321fa57fbfe16c1f4ba10e3a330b29706d1efe59b707e1a4765155960626082368cdeba799dba3d2a5249e13d86f825c9a4a5d0d5220a85a
+MISC ChangeLog-2015 3218 SHA256 4307ba88d07f7363714b1d2e6f81dc4c060ccc8341224d27faafbb4cf23e6c84 SHA512 63475a735b7606bb60d3eaebe0bcdade3c54131fd80acbacd5edc39cef57663d8c45f62cb09a749b2c7b493acaabbb62c4de0037872917f3eb95162f74b94d9f WHIRLPOOL 49810edc0e590e5c2892eaba557a7c1675fe918700b03f67fa590c168d6b5cf5c555de9bf24fb1e8f4f8898eaaefb750713492072c35116cb1a9860c83698b65
+MISC metadata.xml 240 SHA256 07a76e79a43ffd9aa15de0e4ae548ea85aa5bd165c4602630c3519e60f113ee6 SHA512 9c23321eaa853f851bf00195ea64ac2ba093e516f9b57855ee5aa58fbb1988130c9f0c17c2a9ce9fae4ee033e0a28a70c868e0f5acdfa1dd316ab533c5279d59 WHIRLPOOL e3e059953c7c36bd942545f4e2a0e94ba938a17fe2bd04df81b137c185e64a213152c11918922563509e4767e601b41105f80c5983a87ee4d6be7704bcf7cf54
diff --git a/dev-python/pypam/files/PyPAM-0.5.0-dealloc.patch b/dev-python/pypam/files/PyPAM-0.5.0-dealloc.patch
new file mode 100644
index 000000000000..b73dd0b08c59
--- /dev/null
+++ b/dev-python/pypam/files/PyPAM-0.5.0-dealloc.patch
@@ -0,0 +1,17 @@
+diff -up PyPAM-0.5.0/PAMmodule.c.dealloc PyPAM-0.5.0/PAMmodule.c
+--- PyPAM-0.5.0/PAMmodule.c.dealloc 2011-01-17 22:48:22.000000000 +0100
++++ PyPAM-0.5.0/PAMmodule.c 2011-01-18 21:24:59.000000000 +0100
+@@ -538,10 +538,11 @@ static void PyPAM_dealloc(PyPAMObject *s
+ free(self->service);
+ free(self->user);
+ free(self->conv);
+- pam_end(self->pamh, PAM_SUCCESS);
++ if (self->pamh)
++ pam_end(self->pamh, PAM_SUCCESS);
+ dlclose(self->dlh2);
+ dlclose(self->dlh1);
+- PyMem_DEL(self);
++ PyObject_Del(self);
+ }
+
+ static PyObject * PyPAM_getattr(PyPAMObject *self, char *name)
diff --git a/dev-python/pypam/files/PyPAM-0.5.0-memory-errors.patch b/dev-python/pypam/files/PyPAM-0.5.0-memory-errors.patch
new file mode 100644
index 000000000000..6e0b4c0dce4b
--- /dev/null
+++ b/dev-python/pypam/files/PyPAM-0.5.0-memory-errors.patch
@@ -0,0 +1,128 @@
+diff -up PyPAM-0.5.0/PAMmodule.c.memory PyPAM-0.5.0/PAMmodule.c
+--- PyPAM-0.5.0/PAMmodule.c.memory 2012-05-07 17:22:54.503914026 +0200
++++ PyPAM-0.5.0/PAMmodule.c 2012-05-07 17:23:15.644381942 +0200
+@@ -37,33 +37,48 @@ static void PyPAM_Err(PyPAMObject *self,
+
+ err_msg = pam_strerror(self->pamh, result);
+ error = Py_BuildValue("(si)", err_msg, result);
+- Py_INCREF(PyPAM_Error);
+ PyErr_SetObject(PyPAM_Error, error);
++ Py_XDECREF(error);
+ }
+
+ static int PyPAM_conv(int num_msg, const struct pam_message **msg,
+ struct pam_response **resp, void *appdata_ptr)
+ {
+- PyObject *args;
+-
++ PyObject *args, *msgList, *respList, *item;
++ struct pam_response *response, *spr;
+ PyPAMObject* self = (PyPAMObject *) appdata_ptr;
++
+ if (self->callback == NULL)
+ return PAM_CONV_ERR;
+
+ Py_INCREF(self);
+
+- PyObject* msgList = PyList_New(num_msg);
+-
++ msgList = PyList_New(num_msg);
++ if (msgList == NULL) {
++ Py_DECREF(self);
++ return PAM_CONV_ERR;
++ }
++
+ for (int i = 0; i < num_msg; i++) {
+- PyList_SetItem(msgList, i,
+- Py_BuildValue("(si)", msg[i]->msg, msg[i]->msg_style));
++ item = Py_BuildValue("(si)", msg[i]->msg, msg[i]->msg_style);
++ if (item == NULL) {
++ Py_DECREF(msgList);
++ Py_DECREF(self);
++ return PAM_CONV_ERR;
++ }
++ PyList_SetItem(msgList, i, item);
+ }
+-
++
+ args = Py_BuildValue("(OO)", self, msgList);
+- PyObject* respList = PyEval_CallObject(self->callback, args);
++ if (args == NULL) {
++ Py_DECREF(self);
++ Py_DECREF(msgList);
++ return PAM_CONV_ERR;
++ }
++ respList = PyEval_CallObject(self->callback, args);
+ Py_DECREF(args);
+ Py_DECREF(self);
+-
++
+ if (respList == NULL)
+ return PAM_CONV_ERR;
+
+@@ -71,11 +86,15 @@ static int PyPAM_conv(int num_msg, const
+ Py_DECREF(respList);
+ return PAM_CONV_ERR;
+ }
+-
+- *resp = (struct pam_response *) malloc(
++
++ response = (struct pam_response *) malloc(
+ PyList_Size(respList) * sizeof(struct pam_response));
++ if (response == NULL) {
++ Py_DECREF(respList);
++ return PAM_CONV_ERR;
++ }
++ spr = response;
+
+- struct pam_response* spr = *resp;
+ for (int i = 0; i < PyList_Size(respList); i++, spr++) {
+ PyObject* respTuple = PyList_GetItem(respList, i);
+ char* resp_text;
+@@ -85,7 +104,7 @@ static int PyPAM_conv(int num_msg, const
+ free((--spr)->resp);
+ --i;
+ }
+- free(*resp);
++ free(response);
+ Py_DECREF(respList);
+ return PAM_CONV_ERR;
+ }
+@@ -95,7 +114,8 @@ static int PyPAM_conv(int num_msg, const
+ }
+
+ Py_DECREF(respList);
+-
++ *resp = response;
++
+ return PAM_SUCCESS;
+ }
+
+@@ -122,7 +142,11 @@ static PyObject * PyPAM_pam(PyObject *se
+ PyPAMObject_Type.ob_type = &PyType_Type;
+ p = (PyPAMObject *) PyObject_NEW(PyPAMObject, &PyPAMObject_Type);
+
++ if (p == NULL)
++ return NULL;
++
+ if ((spc = (struct pam_conv *) malloc(sizeof(struct pam_conv))) == NULL) {
++ Py_DECREF((PyObject *)p);
+ PyErr_SetString(PyExc_MemoryError, "out of memory");
+ return NULL;
+ }
+@@ -455,9 +479,15 @@ static PyObject * PyPAM_getenvlist(PyObj
+ }
+
+ retval = PyList_New(0);
++ if (retval == NULL)
++ return NULL;
+
+ while ((cp = *(result++)) != NULL) {
+ entry = Py_BuildValue("s", cp);
++ if (entry == NULL) {
++ Py_DECREF(retval);
++ return NULL;
++ }
+ PyList_Append(retval, entry);
+ Py_DECREF(entry);
+ }
diff --git a/dev-python/pypam/files/PyPAM-0.5.0-nofree.patch b/dev-python/pypam/files/PyPAM-0.5.0-nofree.patch
new file mode 100644
index 000000000000..f27e9d543d06
--- /dev/null
+++ b/dev-python/pypam/files/PyPAM-0.5.0-nofree.patch
@@ -0,0 +1,60 @@
+diff --git a/PAMmodule.c b/PAMmodule.c
+index 03cb799..a7ff8a5 100644
+--- a/PAMmodule.c
++++ b/PAMmodule.c
+@@ -24,8 +24,6 @@ typedef struct {
+ char *service;
+ char *user;
+ PyObject *callback;
+- struct pam_response *response_data;
+- int response_len;
+ PyObject *user_data;
+ void *dlh1, *dlh2;
+ } PyPAMObject;
+@@ -54,15 +52,6 @@ static int PyPAM_conv(int num_msg, const struct pam_message **msg,
+
+ Py_INCREF(self);
+
+- if (NULL != self->response_data) {
+- for (int i = 0; i < self->response_len; i++) {
+- free(self->response_data[0].resp);
+- }
+- free(self->response_data);
+- self->response_data = NULL;
+- self->response_len = 0;
+- }
+-
+ PyObject* msgList = PyList_New(num_msg);
+
+ for (int i = 0; i < num_msg; i++) {
+@@ -92,6 +81,10 @@ static int PyPAM_conv(int num_msg, const struct pam_message **msg,
+ char* resp_text;
+ int resp_retcode = 0;
+ if (!PyArg_ParseTuple(respTuple, "si", &resp_text, &resp_retcode)) {
++ while (i > 0) {
++ free((--spr)->resp);
++ --i;
++ }
+ free(*resp);
+ Py_DECREF(respList);
+ return PAM_CONV_ERR;
+@@ -100,10 +93,6 @@ static int PyPAM_conv(int num_msg, const struct pam_message **msg,
+ spr->resp_retcode = resp_retcode;
+ Py_DECREF(respTuple);
+ }
+-
+- // Save this so we can free it later.
+- self->response_data = *resp;
+- self->response_len = PyList_Size(respList);
+
+ Py_DECREF(respList);
+
+@@ -144,8 +133,6 @@ static PyObject * PyPAM_pam(PyObject *self, PyObject *args)
+ p->user = NULL;
+ Py_INCREF(Py_None);
+ p->callback = Py_None;
+- p->response_data = NULL;
+- p->response_len = 0;
+ Py_INCREF(Py_None);
+ p->user_data = Py_None;
+
diff --git a/dev-python/pypam/files/PyPAM-0.5.0-return-value.patch b/dev-python/pypam/files/PyPAM-0.5.0-return-value.patch
new file mode 100644
index 000000000000..6e771e9949a3
--- /dev/null
+++ b/dev-python/pypam/files/PyPAM-0.5.0-return-value.patch
@@ -0,0 +1,57 @@
+diff -up PyPAM-0.5.0/PAMmodule.c.retval PyPAM-0.5.0/PAMmodule.c
+--- PyPAM-0.5.0/PAMmodule.c.retval 2012-05-04 21:47:51.000000000 +0200
++++ PyPAM-0.5.0/PAMmodule.c 2012-05-07 09:42:27.690963206 +0200
+@@ -248,7 +248,7 @@ static PyObject * PyPAM_setcred(PyObject
+ result = pam_setcred(_self->pamh, flags);
+
+ if (result != PAM_SUCCESS) {
+- PyErr_SetString(PyPAM_Error, "Not authenticated");
++ PyPAM_Err(_self, result);
+ return NULL;
+ }
+
+@@ -270,7 +270,7 @@ static PyObject * PyPAM_acct_mgmt(PyObje
+ result = pam_acct_mgmt(_self->pamh, flags);
+
+ if (result != PAM_SUCCESS) {
+- PyErr_SetString(PyPAM_Error, "Not authenticated");
++ PyPAM_Err(_self, result);
+ return NULL;
+ }
+
+@@ -292,7 +292,7 @@ static PyObject * PyPAM_chauthtok(PyObje
+ result = pam_chauthtok(_self->pamh, flags);
+
+ if (result != PAM_SUCCESS) {
+- PyErr_SetString(PyPAM_Error, "Not authenticated");
++ PyPAM_Err(_self, result);
+ return NULL;
+ }
+
+@@ -314,7 +314,7 @@ static PyObject * PyPAM_open_session(PyO
+ result = pam_open_session(_self->pamh, flags);
+
+ if (result != PAM_SUCCESS) {
+- PyErr_SetString(PyPAM_Error, "Not authenticated");
++ PyPAM_Err(_self, result);
+ return NULL;
+ }
+
+@@ -336,7 +336,7 @@ static PyObject * PyPAM_close_session(Py
+ result = pam_close_session(_self->pamh, flags);
+
+ if (result != PAM_SUCCESS) {
+- PyErr_SetString(PyPAM_Error, "Not authenticated");
++ PyPAM_Err(_self, result);
+ return NULL;
+ }
+
+@@ -433,7 +433,7 @@ static PyObject * PyPAM_putenv(PyObject
+ result = pam_putenv(_self->pamh, val);
+
+ if (result != PAM_SUCCESS) {
+- PyErr_SetString(PyPAM_Error, "Not authenticated");
++ PyPAM_Err(_self, result);
+ return NULL;
+ }
+
diff --git a/dev-python/pypam/files/PyPAM-python3-support.patch b/dev-python/pypam/files/PyPAM-python3-support.patch
new file mode 100644
index 000000000000..2aec60eabdf4
--- /dev/null
+++ b/dev-python/pypam/files/PyPAM-python3-support.patch
@@ -0,0 +1,198 @@
+--- PAMmodule.c.python3 2014-06-24 11:29:10.958299393 +0200
++++ PAMmodule.c 2014-06-24 15:20:02.728118493 +0200
+@@ -15,6 +15,14 @@
+ #include <stdio.h>
+ #include <dlfcn.h>
+
++#if PY_MAJOR_VERSION >= 3
++#define IS_PY3K
++#else
++// include bytesobject.h to map PyBytes_* to PyString_*
++#include <bytesobject.h>
++#endif
++
++
+ static PyObject *PyPAM_Error;
+
+ typedef struct {
+@@ -28,7 +36,11 @@
+ void *dlh1, *dlh2;
+ } PyPAMObject;
+
++#ifdef IS_PY3K
++static PyTypeObject PyPAMObject_Type;
++#else
+ staticforward PyTypeObject PyPAMObject_Type;
++#endif
+
+ static void PyPAM_Err(PyPAMObject *self, int result)
+ {
+@@ -139,7 +151,6 @@
+ return NULL;
+ }
+
+- PyPAMObject_Type.ob_type = &PyType_Type;
+ p = (PyPAMObject *) PyObject_NEW(PyPAMObject, &PyPAMObject_Type);
+
+ if (p == NULL)
+@@ -562,35 +573,44 @@
+ PyObject_Del(self);
+ }
+
+-static PyObject * PyPAM_getattr(PyPAMObject *self, char *name)
+-{
+- return Py_FindMethod(PyPAMObject_Methods, (PyObject *) self, name);
+-}
+-
+ static PyObject * PyPAM_repr(PyPAMObject *self)
+ {
+ char buf[1024];
+
+ snprintf(buf, 1024, "<pam object, service=\"%s\", user=\"%s\", conv=%p, pamh=%p>",
+ self->service, self->user, self->conv, self->pamh);
+- return PyString_FromString(buf);
++ return PyBytes_FromString(buf);
+ }
+
+ static PyTypeObject PyPAMObject_Type = {
+- PyObject_HEAD_INIT(0) /* Must fill in type value later */
+- 0,
+- "pam",
+- sizeof(PyPAMObject),
+- 0,
+- (destructor)PyPAM_dealloc, /*tp_dealloc*/
+- 0, /*tp_print*/
+- (getattrfunc)PyPAM_getattr, /*tp_getattr*/
+- 0, /*tp_setattr*/
+- 0, /*tp_compare*/
+- (reprfunc)PyPAM_repr, /*tp_repr*/
+- 0, /*tp_as_number*/
+- 0, /*tp_as_sequence*/
+- 0, /*tp_as_mapping*/
++ PyVarObject_HEAD_INIT(NULL, 0) /* Must fill in type value later */
++ "pam", /* tp_name */
++ sizeof(PyPAMObject), /* tp_basicsize */
++ 0, /* tp_itemsize */
++ (destructor)PyPAM_dealloc, /* tp_dealloc */
++ 0, /* tp_print */
++ 0, /* tp_getattr */
++ 0, /* tp_setattr */
++ 0, /* tp_compare */
++ (reprfunc)PyPAM_repr, /* tp_repr */
++ 0, /* tp_as_number */
++ 0, /* tp_as_sequence */
++ 0, /* tp_as_mapping */
++ 0, /* tp_hash */
++ 0, /* tp_call */
++ 0, /* tp_str */
++ PyObject_GenericGetAttr, /* tp_getattro */
++ 0, /* tp_setattro */
++ 0, /* tp_as_buffer */
++ Py_TPFLAGS_DEFAULT, /* tp_flags */
++ "PyPAM", /* tp_doc */
++ 0, /* tp_traverse */
++ 0, /* tp_clear */
++ 0, /* tp_richcompare */
++ 0, /* tp_weaklistoffset */
++ 0, /* tp_iter */
++ 0, /* tp_iternext */
++ PyPAMObject_Methods, /* tp_methods */
+ };
+
+ static PyMethodDef PyPAM_Methods[] = {
+@@ -607,7 +627,12 @@
+ */
+ static void insint(PyObject *d, char *name, int value)
+ {
+- PyObject* v = PyInt_FromLong((long) value);
++ PyObject* v;
++#ifdef IS_PY3K
++ v = PyLong_FromLong((long) value);
++#else
++ v = PyInt_FromLong((long) value);
++#endif
+
+ if (!v || PyDict_SetItemString(d, name, v))
+ PyErr_Clear();
+@@ -615,19 +640,42 @@
+ Py_XDECREF(v);
+ }
+
++#ifdef IS_PY3K
++static struct PyModuleDef pamdef = {
++ PyModuleDef_HEAD_INIT,
++ "PAM",
++ NULL,
++ -1,
++ PyPAM_Methods,
++ NULL,
++ NULL,
++ NULL,
++ NULL
++};
++
++#define INITERROR return NULL
++PyObject *PyInit_PAM(void)
++
++#else
++#define INITERROR return
+ void initPAM(void)
++#endif
+ {
+ PyObject *m, *d;
+
++#ifdef IS_PY3K
++ m = PyModule_Create(&pamdef);
++#else
+ m = Py_InitModule("PAM", PyPAM_Methods);
++#endif
+ d = PyModule_GetDict(m);
+
+ PyPAM_Error = PyErr_NewException("PAM.error", NULL, NULL);
+ if (PyPAM_Error == NULL)
+- return;
++ INITERROR;
+ PyDict_SetItemString(d, "error", PyPAM_Error);
+
+- PyPAMObject_Type.ob_type = &PyType_Type;
++ Py_TYPE(&PyPAMObject_Type) = &PyType_Type;
+ PyPAMObject_Type.tp_doc = PyPAMObject_doc;
+ Py_INCREF(&PyPAMObject_Type);
+
+@@ -692,4 +740,7 @@
+ insint(d, "PAM_BINARY_PROMPT", PAM_BINARY_PROMPT);
+ #endif
+
++#ifdef IS_PY3K
++ return m;
++#endif
+ }
+--- setup.py.python3 2014-06-24 15:58:07.792172439 +0200
++++ setup.py 2014-06-24 15:58:13.714909021 +0200
+@@ -12,7 +12,7 @@
+ license='LGPL',
+ ext_modules=[
+ Extension(
+- 'PAMmodule',
++ 'PAM',
+ ['PAMmodule.c'],
+ libraries=['pam', 'pam_misc'],
+ extra_compile_args = ['-std=c99'],
+--- tests/PamTest.py.python3 2014-06-24 16:54:28.902998249 +0200
++++ tests/PamTest.py 2014-06-24 17:07:11.392094775 +0200
+@@ -41,13 +41,13 @@
+ def test_userdata_default(self):
+ """The default value for userdata is None."""
+
+- self.failUnless(self.pam.get_userdata() is None)
++ self.assertTrue(self.pam.get_userdata() is None)
+
+ def test_userdata(self):
+ """The userdata getter and setter will store and return any data."""
+
+ self.pam.set_userdata(1)
+- self.failUnless(self.pam.get_userdata() == 1)
++ self.assertTrue(self.pam.get_userdata() == 1)
+
+ def test_start(self):
+ """pam.start() works as expected."""
diff --git a/dev-python/pypam/files/pypam-0.5.0-stricter.patch b/dev-python/pypam/files/pypam-0.5.0-stricter.patch
new file mode 100644
index 000000000000..453910349134
--- /dev/null
+++ b/dev-python/pypam/files/pypam-0.5.0-stricter.patch
@@ -0,0 +1,15 @@
+=== modified file 'PAMmodule.c'
+--- PAMmodule.c 2007-05-28 17:50:59 +0000
++++ PAMmodule.c 2007-05-28 18:13:33 +0000
+@@ -9,8 +9,9 @@
+
++#include <Python.h>
+ #include <security/pam_appl.h>
+ #include <security/pam_misc.h>
+-#include <Python.h>
+ #include <stdio.h>
++#include <string.h>
+ #include <dlfcn.h>
+
+ static PyObject *PyPAM_Error;
+
diff --git a/dev-python/pypam/metadata.xml b/dev-python/pypam/metadata.xml
new file mode 100644
index 000000000000..7f4f33c6dbc9
--- /dev/null
+++ b/dev-python/pypam/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="project">
+ <email>python@gentoo.org</email>
+ <name>Python</name>
+ </maintainer>
+</pkgmetadata>
diff --git a/dev-python/pypam/pypam-0.5.0-r3.ebuild b/dev-python/pypam/pypam-0.5.0-r3.ebuild
new file mode 100644
index 000000000000..4ed08707692a
--- /dev/null
+++ b/dev-python/pypam/pypam-0.5.0-r3.ebuild
@@ -0,0 +1,46 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+PYTHON_COMPAT=( python{2_7,3_4,3_5,3_6} )
+
+inherit distutils-r1 flag-o-matic
+
+MY_PN="PyPAM"
+MY_P="${MY_PN}-${PV}"
+
+DESCRIPTION="Python Bindings for PAM (Pluggable Authentication Modules)"
+HOMEPAGE="http://www.pangalactic.org/PyPAM"
+SRC_URI="http://www.pangalactic.org/PyPAM/${MY_P}.tar.gz"
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="amd64 ~arm ~arm64 x86"
+IUSE=""
+
+DEPEND=">=sys-libs/pam-0.64"
+RDEPEND="${DEPEND}"
+
+S="${WORKDIR}/${MY_P}"
+
+DOCS=( AUTHORS examples/pamtest.py )
+
+PATCHES=(
+ # Pull patches from fedora.
+ "${FILESDIR}/PyPAM-${PV}-dealloc.patch"
+ "${FILESDIR}/PyPAM-${PV}-nofree.patch"
+ "${FILESDIR}/PyPAM-${PV}-memory-errors.patch"
+ "${FILESDIR}/PyPAM-${PV}-return-value.patch"
+ "${FILESDIR}/PyPAM-python3-support.patch"
+ # Fix a missing include.
+ "${FILESDIR}/${P}-stricter.patch"
+)
+
+src_compile() {
+ append-cflags -fno-strict-aliasing
+ distutils-r1_src_compile
+}
+
+python_test() {
+ "${PYTHON}" tests/PamTest.py
+}