diff options
author | Francesco Colista <fcolista@alpinelinux.org> | 2016-12-15 07:45:15 +0000 |
---|---|---|
committer | Francesco Colista <fcolista@alpinelinux.org> | 2016-12-15 07:45:15 +0000 |
commit | 6928abc43e245aae98a620afa35a1c76c7e55417 (patch) | |
tree | cf1570ab2690681d6101b8b752f1871250c85dd8 | |
parent | 0648d40beb7f4599fae6376eb7e1eda69a6b0266 (diff) | |
download | alpine_aports-6928abc43e245aae98a620afa35a1c76c7e55417.tar.bz2 alpine_aports-6928abc43e245aae98a620afa35a1c76c7e55417.tar.xz alpine_aports-6928abc43e245aae98a620afa35a1c76c7e55417.zip |
testing/py-pam: new aport
-rw-r--r-- | testing/py-pam/APKBUILD | 71 | ||||
-rw-r--r-- | testing/py-pam/PyPAM-0.5.0-dealloc.patch | 17 | ||||
-rw-r--r-- | testing/py-pam/PyPAM-0.5.0-memory-errors.patch | 128 | ||||
-rw-r--r-- | testing/py-pam/PyPAM-0.5.0-nofree.patch | 60 | ||||
-rw-r--r-- | testing/py-pam/PyPAM-0.5.0-return-value.patch | 57 | ||||
-rw-r--r-- | testing/py-pam/PyPAM-python3-support.patch | 198 | ||||
-rw-r--r-- | testing/py-pam/pypam-0.5.0-stricter.patch | 15 |
7 files changed, 546 insertions, 0 deletions
diff --git a/testing/py-pam/APKBUILD b/testing/py-pam/APKBUILD new file mode 100644 index 0000000000..d1bb0a24e8 --- /dev/null +++ b/testing/py-pam/APKBUILD | |||
@@ -0,0 +1,71 @@ | |||
1 | # Contributor: Francesco Colista <fcolista@alpinelinux.org> | ||
2 | # Maintainer: Francesco Colista <fcolista@alpinelinux.org> | ||
3 | pkgname=py-pam | ||
4 | _pkgname=PyPAM | ||
5 | _id="f1e7c2c56421dda28a75ace59a3c8871" | ||
6 | pkgver=0.5.0 | ||
7 | pkgrel=0 | ||
8 | pkgdesc="A Python interface to the PAM library " | ||
9 | url="https://launchpad.net/ubuntu/quantal/+source/python-pam" | ||
10 | arch="all" | ||
11 | license="LGPL-2.1" | ||
12 | depends="linux-pam" | ||
13 | makedepends="python2-dev py-setuptools python3-dev linux-headers linux-pam-dev" | ||
14 | subpackages="py3-${pkgname/py-/}:_py3 py2-${pkgname/py-/}:_py2" | ||
15 | source="http://pkgs.fedoraproject.org/lookaside/pkgs/$_pkgname/$_pkgname-$pkgver.tar.gz/$_id/$_pkgname-$pkgver.tar.gz | ||
16 | PyPAM-0.5.0-dealloc.patch | ||
17 | PyPAM-0.5.0-nofree.patch | ||
18 | PyPAM-0.5.0-memory-errors.patch | ||
19 | PyPAM-0.5.0-return-value.patch | ||
20 | PyPAM-python3-support.patch | ||
21 | pypam-0.5.0-stricter.patch" | ||
22 | builddir="$srcdir"/$_pkgname-$pkgver | ||
23 | |||
24 | build() { | ||
25 | cd "$builddir" | ||
26 | python2 setup.py build || return 1 | ||
27 | python3 setup.py build || return 1 | ||
28 | } | ||
29 | |||
30 | package() { | ||
31 | mkdir -p "$pkgdir" | ||
32 | } | ||
33 | |||
34 | _py() { | ||
35 | local python=$1 | ||
36 | pkgdesc="$pkgdesc (for $python)" | ||
37 | install_if="$pkgname=$pkgver-r$pkgrel $python" | ||
38 | cd "$builddir" | ||
39 | $python setup.py install --prefix=/usr --root="$subpkgdir" | ||
40 | } | ||
41 | |||
42 | _py2() { | ||
43 | replaces="$pkgname" | ||
44 | _py python2 | ||
45 | } | ||
46 | |||
47 | _py3() { | ||
48 | _py python3 | ||
49 | } | ||
50 | |||
51 | md5sums="f1e7c2c56421dda28a75ace59a3c8871 PyPAM-0.5.0.tar.gz | ||
52 | 1c893c85d63378bb05d8cd07bffc97e7 PyPAM-0.5.0-dealloc.patch | ||
53 | 0663d74895ca602bf184e1898a34116d PyPAM-0.5.0-nofree.patch | ||
54 | 9ee809416aa3ab00655043f01cd3522f PyPAM-0.5.0-memory-errors.patch | ||
55 | 6a7ea0a074f5b51598da4ee3bbbb95ee PyPAM-0.5.0-return-value.patch | ||
56 | ad43b2cbee367cdcb9c6fbd0d3c1cf48 PyPAM-python3-support.patch | ||
57 | da0356df36055b1175e14643d6163e01 pypam-0.5.0-stricter.patch" | ||
58 | sha256sums="796ac019b9ee805696d0d277d8fb912fa2391b6ac070dc6f9f1a9a0fadbc3a5a PyPAM-0.5.0.tar.gz | ||
59 | 5d73ad2efb9b5f0507c1968aa69bcc36d3981e5c02117215982abbb6825863de PyPAM-0.5.0-dealloc.patch | ||
60 | ed2964fbc2c0d8b23961cf3a9b5b77d8c4609de54ef0e557ecb64664497f8ff9 PyPAM-0.5.0-nofree.patch | ||
61 | e500628d9ccae7c953967a70a97b3af94c5f6c52849b6615b0d1270789a1d08a PyPAM-0.5.0-memory-errors.patch | ||
62 | 8a5a7292b415b053a69ccb36f7cd5dfd367f273b0ca8cf1f1bcec96f05769b3e PyPAM-0.5.0-return-value.patch | ||
63 | e51058c0869eb0b5364c1978f865ceea01f8b9e9957695629ce61bf8417838b0 PyPAM-python3-support.patch | ||
64 | ad12759aeb86af08c590c91995ef36ee8e887523f8a2cf49b28e1e9034608d6c pypam-0.5.0-stricter.patch" | ||
65 | sha512sums="9e0e919e34930d2283307cd6665c5287c664a76a5de56367bd975867ac26b376ae03d30cb3bc4a16390c977ca2690cfd2e90ac73dcc7886b8c999444da4a07e0 PyPAM-0.5.0.tar.gz | ||
66 | 105573489be31763ed01bab02ccaf7147c73b196d85d8318eceda145e86fb5c3fa3a59b7baee9d85f6d5ae40df0335689267650461f5440a9c2991954c367e8e PyPAM-0.5.0-dealloc.patch | ||
67 | 7292483d60f75d577055f4bf7380b110620669a19b3e2e3a4700e2c816758af865213cf19b329260338e82f9a0cba03a14dea06ba636251f1436ec0c3373f751 PyPAM-0.5.0-nofree.patch | ||
68 | 358e57ba6450b533cbdb39f559813767799e387937a610b15e5e8e78d59b6501785c40c3ffdc5b1914ff6c9220716cdf9b537847373379eb94094f6ffe23c7f5 PyPAM-0.5.0-memory-errors.patch | ||
69 | 73d81d9a7398933011eba0739e3bce7651c3da1bf38f77b510172e26f569d329c3b28e5192a25ee0616875ddad52e67697dabe021d31cc5e51e9e78941333c8d PyPAM-0.5.0-return-value.patch | ||
70 | 4dd78df5984601cf47aebaa77665730c32b4f0550feb8c12af4b145643584aad9d4b184b2c8fb67cc0503ad791a1d772a01db478795407b5c755dcbd172dabd0 PyPAM-python3-support.patch | ||
71 | 8a059951cc219278a36e7e0ec50aba2799d664f74389735e3b32ff2bd7fd45e0d712d0487662879bc07b3bd7fdf74acae7c459dfc16731ad90e8e83b2c215cbd pypam-0.5.0-stricter.patch" | ||
diff --git a/testing/py-pam/PyPAM-0.5.0-dealloc.patch b/testing/py-pam/PyPAM-0.5.0-dealloc.patch new file mode 100644 index 0000000000..b73dd0b08c --- /dev/null +++ b/testing/py-pam/PyPAM-0.5.0-dealloc.patch | |||
@@ -0,0 +1,17 @@ | |||
1 | diff -up PyPAM-0.5.0/PAMmodule.c.dealloc PyPAM-0.5.0/PAMmodule.c | ||
2 | --- PyPAM-0.5.0/PAMmodule.c.dealloc 2011-01-17 22:48:22.000000000 +0100 | ||
3 | +++ PyPAM-0.5.0/PAMmodule.c 2011-01-18 21:24:59.000000000 +0100 | ||
4 | @@ -538,10 +538,11 @@ static void PyPAM_dealloc(PyPAMObject *s | ||
5 | free(self->service); | ||
6 | free(self->user); | ||
7 | free(self->conv); | ||
8 | - pam_end(self->pamh, PAM_SUCCESS); | ||
9 | + if (self->pamh) | ||
10 | + pam_end(self->pamh, PAM_SUCCESS); | ||
11 | dlclose(self->dlh2); | ||
12 | dlclose(self->dlh1); | ||
13 | - PyMem_DEL(self); | ||
14 | + PyObject_Del(self); | ||
15 | } | ||
16 | |||
17 | static PyObject * PyPAM_getattr(PyPAMObject *self, char *name) | ||
diff --git a/testing/py-pam/PyPAM-0.5.0-memory-errors.patch b/testing/py-pam/PyPAM-0.5.0-memory-errors.patch new file mode 100644 index 0000000000..6e0b4c0dce --- /dev/null +++ b/testing/py-pam/PyPAM-0.5.0-memory-errors.patch | |||
@@ -0,0 +1,128 @@ | |||
1 | diff -up PyPAM-0.5.0/PAMmodule.c.memory PyPAM-0.5.0/PAMmodule.c | ||
2 | --- PyPAM-0.5.0/PAMmodule.c.memory 2012-05-07 17:22:54.503914026 +0200 | ||
3 | +++ PyPAM-0.5.0/PAMmodule.c 2012-05-07 17:23:15.644381942 +0200 | ||
4 | @@ -37,33 +37,48 @@ static void PyPAM_Err(PyPAMObject *self, | ||
5 | |||
6 | err_msg = pam_strerror(self->pamh, result); | ||
7 | error = Py_BuildValue("(si)", err_msg, result); | ||
8 | - Py_INCREF(PyPAM_Error); | ||
9 | PyErr_SetObject(PyPAM_Error, error); | ||
10 | + Py_XDECREF(error); | ||
11 | } | ||
12 | |||
13 | static int PyPAM_conv(int num_msg, const struct pam_message **msg, | ||
14 | struct pam_response **resp, void *appdata_ptr) | ||
15 | { | ||
16 | - PyObject *args; | ||
17 | - | ||
18 | + PyObject *args, *msgList, *respList, *item; | ||
19 | + struct pam_response *response, *spr; | ||
20 | PyPAMObject* self = (PyPAMObject *) appdata_ptr; | ||
21 | + | ||
22 | if (self->callback == NULL) | ||
23 | return PAM_CONV_ERR; | ||
24 | |||
25 | Py_INCREF(self); | ||
26 | |||
27 | - PyObject* msgList = PyList_New(num_msg); | ||
28 | - | ||
29 | + msgList = PyList_New(num_msg); | ||
30 | + if (msgList == NULL) { | ||
31 | + Py_DECREF(self); | ||
32 | + return PAM_CONV_ERR; | ||
33 | + } | ||
34 | + | ||
35 | for (int i = 0; i < num_msg; i++) { | ||
36 | - PyList_SetItem(msgList, i, | ||
37 | - Py_BuildValue("(si)", msg[i]->msg, msg[i]->msg_style)); | ||
38 | + item = Py_BuildValue("(si)", msg[i]->msg, msg[i]->msg_style); | ||
39 | + if (item == NULL) { | ||
40 | + Py_DECREF(msgList); | ||
41 | + Py_DECREF(self); | ||
42 | + return PAM_CONV_ERR; | ||
43 | + } | ||
44 | + PyList_SetItem(msgList, i, item); | ||
45 | } | ||
46 | - | ||
47 | + | ||
48 | args = Py_BuildValue("(OO)", self, msgList); | ||
49 | - PyObject* respList = PyEval_CallObject(self->callback, args); | ||
50 | + if (args == NULL) { | ||
51 | + Py_DECREF(self); | ||
52 | + Py_DECREF(msgList); | ||
53 | + return PAM_CONV_ERR; | ||
54 | + } | ||
55 | + respList = PyEval_CallObject(self->callback, args); | ||
56 | Py_DECREF(args); | ||
57 | Py_DECREF(self); | ||
58 | - | ||
59 | + | ||
60 | if (respList == NULL) | ||
61 | return PAM_CONV_ERR; | ||
62 | |||
63 | @@ -71,11 +86,15 @@ static int PyPAM_conv(int num_msg, const | ||
64 | Py_DECREF(respList); | ||
65 | return PAM_CONV_ERR; | ||
66 | } | ||
67 | - | ||
68 | - *resp = (struct pam_response *) malloc( | ||
69 | + | ||
70 | + response = (struct pam_response *) malloc( | ||
71 | PyList_Size(respList) * sizeof(struct pam_response)); | ||
72 | + if (response == NULL) { | ||
73 | + Py_DECREF(respList); | ||
74 | + return PAM_CONV_ERR; | ||
75 | + } | ||
76 | + spr = response; | ||
77 | |||
78 | - struct pam_response* spr = *resp; | ||
79 | for (int i = 0; i < PyList_Size(respList); i++, spr++) { | ||
80 | PyObject* respTuple = PyList_GetItem(respList, i); | ||
81 | char* resp_text; | ||
82 | @@ -85,7 +104,7 @@ static int PyPAM_conv(int num_msg, const | ||
83 | free((--spr)->resp); | ||
84 | --i; | ||
85 | } | ||
86 | - free(*resp); | ||
87 | + free(response); | ||
88 | Py_DECREF(respList); | ||
89 | return PAM_CONV_ERR; | ||
90 | } | ||
91 | @@ -95,7 +114,8 @@ static int PyPAM_conv(int num_msg, const | ||
92 | } | ||
93 | |||
94 | Py_DECREF(respList); | ||
95 | - | ||
96 | + *resp = response; | ||
97 | + | ||
98 | return PAM_SUCCESS; | ||
99 | } | ||
100 | |||
101 | @@ -122,7 +142,11 @@ static PyObject * PyPAM_pam(PyObject *se | ||
102 | PyPAMObject_Type.ob_type = &PyType_Type; | ||
103 | p = (PyPAMObject *) PyObject_NEW(PyPAMObject, &PyPAMObject_Type); | ||
104 | |||
105 | + if (p == NULL) | ||
106 | + return NULL; | ||
107 | + | ||
108 | if ((spc = (struct pam_conv *) malloc(sizeof(struct pam_conv))) == NULL) { | ||
109 | + Py_DECREF((PyObject *)p); | ||
110 | PyErr_SetString(PyExc_MemoryError, "out of memory"); | ||
111 | return NULL; | ||
112 | } | ||
113 | @@ -455,9 +479,15 @@ static PyObject * PyPAM_getenvlist(PyObj | ||
114 | } | ||
115 | |||
116 | retval = PyList_New(0); | ||
117 | + if (retval == NULL) | ||
118 | + return NULL; | ||
119 | |||
120 | while ((cp = *(result++)) != NULL) { | ||
121 | entry = Py_BuildValue("s", cp); | ||
122 | + if (entry == NULL) { | ||
123 | + Py_DECREF(retval); | ||
124 | + return NULL; | ||
125 | + } | ||
126 | PyList_Append(retval, entry); | ||
127 | Py_DECREF(entry); | ||
128 | } | ||
diff --git a/testing/py-pam/PyPAM-0.5.0-nofree.patch b/testing/py-pam/PyPAM-0.5.0-nofree.patch new file mode 100644 index 0000000000..f27e9d543d --- /dev/null +++ b/testing/py-pam/PyPAM-0.5.0-nofree.patch | |||
@@ -0,0 +1,60 @@ | |||
1 | diff --git a/PAMmodule.c b/PAMmodule.c | ||
2 | index 03cb799..a7ff8a5 100644 | ||
3 | --- a/PAMmodule.c | ||
4 | +++ b/PAMmodule.c | ||
5 | @@ -24,8 +24,6 @@ typedef struct { | ||
6 | char *service; | ||
7 | char *user; | ||
8 | PyObject *callback; | ||
9 | - struct pam_response *response_data; | ||
10 | - int response_len; | ||
11 | PyObject *user_data; | ||
12 | void *dlh1, *dlh2; | ||
13 | } PyPAMObject; | ||
14 | @@ -54,15 +52,6 @@ static int PyPAM_conv(int num_msg, const struct pam_message **msg, | ||
15 | |||
16 | Py_INCREF(self); | ||
17 | |||
18 | - if (NULL != self->response_data) { | ||
19 | - for (int i = 0; i < self->response_len; i++) { | ||
20 | - free(self->response_data[0].resp); | ||
21 | - } | ||
22 | - free(self->response_data); | ||
23 | - self->response_data = NULL; | ||
24 | - self->response_len = 0; | ||
25 | - } | ||
26 | - | ||
27 | PyObject* msgList = PyList_New(num_msg); | ||
28 | |||
29 | for (int i = 0; i < num_msg; i++) { | ||
30 | @@ -92,6 +81,10 @@ static int PyPAM_conv(int num_msg, const struct pam_message **msg, | ||
31 | char* resp_text; | ||
32 | int resp_retcode = 0; | ||
33 | if (!PyArg_ParseTuple(respTuple, "si", &resp_text, &resp_retcode)) { | ||
34 | + while (i > 0) { | ||
35 | + free((--spr)->resp); | ||
36 | + --i; | ||
37 | + } | ||
38 | free(*resp); | ||
39 | Py_DECREF(respList); | ||
40 | return PAM_CONV_ERR; | ||
41 | @@ -100,10 +93,6 @@ static int PyPAM_conv(int num_msg, const struct pam_message **msg, | ||
42 | spr->resp_retcode = resp_retcode; | ||
43 | Py_DECREF(respTuple); | ||
44 | } | ||
45 | - | ||
46 | - // Save this so we can free it later. | ||
47 | - self->response_data = *resp; | ||
48 | - self->response_len = PyList_Size(respList); | ||
49 | |||
50 | Py_DECREF(respList); | ||
51 | |||
52 | @@ -144,8 +133,6 @@ static PyObject * PyPAM_pam(PyObject *self, PyObject *args) | ||
53 | p->user = NULL; | ||
54 | Py_INCREF(Py_None); | ||
55 | p->callback = Py_None; | ||
56 | - p->response_data = NULL; | ||
57 | - p->response_len = 0; | ||
58 | Py_INCREF(Py_None); | ||
59 | p->user_data = Py_None; | ||
60 | |||
diff --git a/testing/py-pam/PyPAM-0.5.0-return-value.patch b/testing/py-pam/PyPAM-0.5.0-return-value.patch new file mode 100644 index 0000000000..6e771e9949 --- /dev/null +++ b/testing/py-pam/PyPAM-0.5.0-return-value.patch | |||
@@ -0,0 +1,57 @@ | |||
1 | diff -up PyPAM-0.5.0/PAMmodule.c.retval PyPAM-0.5.0/PAMmodule.c | ||
2 | --- PyPAM-0.5.0/PAMmodule.c.retval 2012-05-04 21:47:51.000000000 +0200 | ||
3 | +++ PyPAM-0.5.0/PAMmodule.c 2012-05-07 09:42:27.690963206 +0200 | ||
4 | @@ -248,7 +248,7 @@ static PyObject * PyPAM_setcred(PyObject | ||
5 | result = pam_setcred(_self->pamh, flags); | ||
6 | |||
7 | if (result != PAM_SUCCESS) { | ||
8 | - PyErr_SetString(PyPAM_Error, "Not authenticated"); | ||
9 | + PyPAM_Err(_self, result); | ||
10 | return NULL; | ||
11 | } | ||
12 | |||
13 | @@ -270,7 +270,7 @@ static PyObject * PyPAM_acct_mgmt(PyObje | ||
14 | result = pam_acct_mgmt(_self->pamh, flags); | ||
15 | |||
16 | if (result != PAM_SUCCESS) { | ||
17 | - PyErr_SetString(PyPAM_Error, "Not authenticated"); | ||
18 | + PyPAM_Err(_self, result); | ||
19 | return NULL; | ||
20 | } | ||
21 | |||
22 | @@ -292,7 +292,7 @@ static PyObject * PyPAM_chauthtok(PyObje | ||
23 | result = pam_chauthtok(_self->pamh, flags); | ||
24 | |||
25 | if (result != PAM_SUCCESS) { | ||
26 | - PyErr_SetString(PyPAM_Error, "Not authenticated"); | ||
27 | + PyPAM_Err(_self, result); | ||
28 | return NULL; | ||
29 | } | ||
30 | |||
31 | @@ -314,7 +314,7 @@ static PyObject * PyPAM_open_session(PyO | ||
32 | result = pam_open_session(_self->pamh, flags); | ||
33 | |||
34 | if (result != PAM_SUCCESS) { | ||
35 | - PyErr_SetString(PyPAM_Error, "Not authenticated"); | ||
36 | + PyPAM_Err(_self, result); | ||
37 | return NULL; | ||
38 | } | ||
39 | |||
40 | @@ -336,7 +336,7 @@ static PyObject * PyPAM_close_session(Py | ||
41 | result = pam_close_session(_self->pamh, flags); | ||
42 | |||
43 | if (result != PAM_SUCCESS) { | ||
44 | - PyErr_SetString(PyPAM_Error, "Not authenticated"); | ||
45 | + PyPAM_Err(_self, result); | ||
46 | return NULL; | ||
47 | } | ||
48 | |||
49 | @@ -433,7 +433,7 @@ static PyObject * PyPAM_putenv(PyObject | ||
50 | result = pam_putenv(_self->pamh, val); | ||
51 | |||
52 | if (result != PAM_SUCCESS) { | ||
53 | - PyErr_SetString(PyPAM_Error, "Not authenticated"); | ||
54 | + PyPAM_Err(_self, result); | ||
55 | return NULL; | ||
56 | } | ||
57 | |||
diff --git a/testing/py-pam/PyPAM-python3-support.patch b/testing/py-pam/PyPAM-python3-support.patch new file mode 100644 index 0000000000..58d414f56b --- /dev/null +++ b/testing/py-pam/PyPAM-python3-support.patch | |||
@@ -0,0 +1,198 @@ | |||
1 | --- a/PAMmodule.c.python3 2014-06-24 11:29:10.958299393 +0200 | ||
2 | +++ b/PAMmodule.c 2014-06-24 15:20:02.728118493 +0200 | ||
3 | @@ -15,6 +15,14 @@ | ||
4 | #include <stdio.h> | ||
5 | #include <dlfcn.h> | ||
6 | |||
7 | +#if PY_MAJOR_VERSION >= 3 | ||
8 | +#define IS_PY3K | ||
9 | +#else | ||
10 | +// include bytesobject.h to map PyBytes_* to PyString_* | ||
11 | +#include <bytesobject.h> | ||
12 | +#endif | ||
13 | + | ||
14 | + | ||
15 | static PyObject *PyPAM_Error; | ||
16 | |||
17 | typedef struct { | ||
18 | @@ -28,7 +36,11 @@ | ||
19 | void *dlh1, *dlh2; | ||
20 | } PyPAMObject; | ||
21 | |||
22 | +#ifdef IS_PY3K | ||
23 | +static PyTypeObject PyPAMObject_Type; | ||
24 | +#else | ||
25 | staticforward PyTypeObject PyPAMObject_Type; | ||
26 | +#endif | ||
27 | |||
28 | static void PyPAM_Err(PyPAMObject *self, int result) | ||
29 | { | ||
30 | @@ -139,7 +151,6 @@ | ||
31 | return NULL; | ||
32 | } | ||
33 | |||
34 | - PyPAMObject_Type.ob_type = &PyType_Type; | ||
35 | p = (PyPAMObject *) PyObject_NEW(PyPAMObject, &PyPAMObject_Type); | ||
36 | |||
37 | if (p == NULL) | ||
38 | @@ -562,35 +573,44 @@ | ||
39 | PyObject_Del(self); | ||
40 | } | ||
41 | |||
42 | -static PyObject * PyPAM_getattr(PyPAMObject *self, char *name) | ||
43 | -{ | ||
44 | - return Py_FindMethod(PyPAMObject_Methods, (PyObject *) self, name); | ||
45 | -} | ||
46 | - | ||
47 | static PyObject * PyPAM_repr(PyPAMObject *self) | ||
48 | { | ||
49 | char buf[1024]; | ||
50 | |||
51 | snprintf(buf, 1024, "<pam object, service=\"%s\", user=\"%s\", conv=%p, pamh=%p>", | ||
52 | self->service, self->user, self->conv, self->pamh); | ||
53 | - return PyString_FromString(buf); | ||
54 | + return PyBytes_FromString(buf); | ||
55 | } | ||
56 | |||
57 | static PyTypeObject PyPAMObject_Type = { | ||
58 | - PyObject_HEAD_INIT(0) /* Must fill in type value later */ | ||
59 | - 0, | ||
60 | - "pam", | ||
61 | - sizeof(PyPAMObject), | ||
62 | - 0, | ||
63 | - (destructor)PyPAM_dealloc, /*tp_dealloc*/ | ||
64 | - 0, /*tp_print*/ | ||
65 | - (getattrfunc)PyPAM_getattr, /*tp_getattr*/ | ||
66 | - 0, /*tp_setattr*/ | ||
67 | - 0, /*tp_compare*/ | ||
68 | - (reprfunc)PyPAM_repr, /*tp_repr*/ | ||
69 | - 0, /*tp_as_number*/ | ||
70 | - 0, /*tp_as_sequence*/ | ||
71 | - 0, /*tp_as_mapping*/ | ||
72 | + PyVarObject_HEAD_INIT(NULL, 0) /* Must fill in type value later */ | ||
73 | + "pam", /* tp_name */ | ||
74 | + sizeof(PyPAMObject), /* tp_basicsize */ | ||
75 | + 0, /* tp_itemsize */ | ||
76 | + (destructor)PyPAM_dealloc, /* tp_dealloc */ | ||
77 | + 0, /* tp_print */ | ||
78 | + 0, /* tp_getattr */ | ||
79 | + 0, /* tp_setattr */ | ||
80 | + 0, /* tp_compare */ | ||
81 | + (reprfunc)PyPAM_repr, /* tp_repr */ | ||
82 | + 0, /* tp_as_number */ | ||
83 | + 0, /* tp_as_sequence */ | ||
84 | + 0, /* tp_as_mapping */ | ||
85 | + 0, /* tp_hash */ | ||
86 | + 0, /* tp_call */ | ||
87 | + 0, /* tp_str */ | ||
88 | + PyObject_GenericGetAttr, /* tp_getattro */ | ||
89 | + 0, /* tp_setattro */ | ||
90 | + 0, /* tp_as_buffer */ | ||
91 | + Py_TPFLAGS_DEFAULT, /* tp_flags */ | ||
92 | + "PyPAM", /* tp_doc */ | ||
93 | + 0, /* tp_traverse */ | ||
94 | + 0, /* tp_clear */ | ||
95 | + 0, /* tp_richcompare */ | ||
96 | + 0, /* tp_weaklistoffset */ | ||
97 | + 0, /* tp_iter */ | ||
98 | + 0, /* tp_iternext */ | ||
99 | + PyPAMObject_Methods, /* tp_methods */ | ||
100 | }; | ||
101 | |||
102 | static PyMethodDef PyPAM_Methods[] = { | ||
103 | @@ -607,7 +627,12 @@ | ||
104 | */ | ||
105 | static void insint(PyObject *d, char *name, int value) | ||
106 | { | ||
107 | - PyObject* v = PyInt_FromLong((long) value); | ||
108 | + PyObject* v; | ||
109 | +#ifdef IS_PY3K | ||
110 | + v = PyLong_FromLong((long) value); | ||
111 | +#else | ||
112 | + v = PyInt_FromLong((long) value); | ||
113 | +#endif | ||
114 | |||
115 | if (!v || PyDict_SetItemString(d, name, v)) | ||
116 | PyErr_Clear(); | ||
117 | @@ -615,19 +640,42 @@ | ||
118 | Py_XDECREF(v); | ||
119 | } | ||
120 | |||
121 | +#ifdef IS_PY3K | ||
122 | +static struct PyModuleDef pamdef = { | ||
123 | + PyModuleDef_HEAD_INIT, | ||
124 | + "PAM", | ||
125 | + NULL, | ||
126 | + -1, | ||
127 | + PyPAM_Methods, | ||
128 | + NULL, | ||
129 | + NULL, | ||
130 | + NULL, | ||
131 | + NULL | ||
132 | +}; | ||
133 | + | ||
134 | +#define INITERROR return NULL | ||
135 | +PyObject *PyInit_PAM(void) | ||
136 | + | ||
137 | +#else | ||
138 | +#define INITERROR return | ||
139 | void initPAM(void) | ||
140 | +#endif | ||
141 | { | ||
142 | PyObject *m, *d; | ||
143 | |||
144 | +#ifdef IS_PY3K | ||
145 | + m = PyModule_Create(&pamdef); | ||
146 | +#else | ||
147 | m = Py_InitModule("PAM", PyPAM_Methods); | ||
148 | +#endif | ||
149 | d = PyModule_GetDict(m); | ||
150 | |||
151 | PyPAM_Error = PyErr_NewException("PAM.error", NULL, NULL); | ||
152 | if (PyPAM_Error == NULL) | ||
153 | - return; | ||
154 | + INITERROR; | ||
155 | PyDict_SetItemString(d, "error", PyPAM_Error); | ||
156 | |||
157 | - PyPAMObject_Type.ob_type = &PyType_Type; | ||
158 | + Py_TYPE(&PyPAMObject_Type) = &PyType_Type; | ||
159 | PyPAMObject_Type.tp_doc = PyPAMObject_doc; | ||
160 | Py_INCREF(&PyPAMObject_Type); | ||
161 | |||
162 | @@ -692,4 +740,7 @@ | ||
163 | insint(d, "PAM_BINARY_PROMPT", PAM_BINARY_PROMPT); | ||
164 | #endif | ||
165 | |||
166 | +#ifdef IS_PY3K | ||
167 | + return m; | ||
168 | +#endif | ||
169 | } | ||
170 | --- a/setup.py.python3 2014-06-24 15:58:07.792172439 +0200 | ||
171 | +++ b/setup.py 2014-06-24 15:58:13.714909021 +0200 | ||
172 | @@ -12,7 +12,7 @@ | ||
173 | license='LGPL', | ||
174 | ext_modules=[ | ||
175 | Extension( | ||
176 | - 'PAMmodule', | ||
177 | + 'PAM', | ||
178 | ['PAMmodule.c'], | ||
179 | libraries=['pam', 'pam_misc'], | ||
180 | extra_compile_args = ['-std=c99'], | ||
181 | --- a/tests/PamTest.py.python3 2014-06-24 16:54:28.902998249 +0200 | ||
182 | +++ b/tests/PamTest.py 2014-06-24 17:07:11.392094775 +0200 | ||
183 | @@ -41,13 +41,13 @@ | ||
184 | def test_userdata_default(self): | ||
185 | """The default value for userdata is None.""" | ||
186 | |||
187 | - self.failUnless(self.pam.get_userdata() is None) | ||
188 | + self.assertTrue(self.pam.get_userdata() is None) | ||
189 | |||
190 | def test_userdata(self): | ||
191 | """The userdata getter and setter will store and return any data.""" | ||
192 | |||
193 | self.pam.set_userdata(1) | ||
194 | - self.failUnless(self.pam.get_userdata() == 1) | ||
195 | + self.assertTrue(self.pam.get_userdata() == 1) | ||
196 | |||
197 | def test_start(self): | ||
198 | """pam.start() works as expected.""" | ||
diff --git a/testing/py-pam/pypam-0.5.0-stricter.patch b/testing/py-pam/pypam-0.5.0-stricter.patch new file mode 100644 index 0000000000..4079f6ff71 --- /dev/null +++ b/testing/py-pam/pypam-0.5.0-stricter.patch | |||
@@ -0,0 +1,15 @@ | |||
1 | === modified file 'PAMmodule.c' | ||
2 | --- a/PAMmodule.c 2007-05-28 17:50:59 +0000 | ||
3 | +++ b/PAMmodule.c 2007-05-28 18:13:33 +0000 | ||
4 | @@ -9,8 +9,9 @@ | ||
5 | |||
6 | +#include <Python.h> | ||
7 | #include <security/pam_appl.h> | ||
8 | #include <security/pam_misc.h> | ||
9 | -#include <Python.h> | ||
10 | #include <stdio.h> | ||
11 | +#include <string.h> | ||
12 | #include <dlfcn.h> | ||
13 | |||
14 | static PyObject *PyPAM_Error; | ||
15 | |||