Merge lp:~vorlon/ubuntu/quantal/python-pam/python3 into lp:ubuntu/quantal/python-pam

Proposed by Steve Langasek
Status: Needs review
Proposed branch: lp:~vorlon/ubuntu/quantal/python-pam/python3
Merge into: lp:ubuntu/quantal/python-pam
Diff against target: 333 lines (+107/-78)
11 files modified
PAMmodule.c (+24/-12)
debian/changelog (+14/-0)
debian/compat (+1/-0)
debian/control (+28/-4)
debian/python-pam-dbg.install (+1/-0)
debian/python-pam.examples (+1/-0)
debian/python-pam.install (+2/-0)
debian/python3-pam-dbg.install (+1/-0)
debian/python3-pam.examples (+1/-0)
debian/python3-pam.install (+2/-0)
debian/rules (+32/-62)
To merge this branch: bzr merge lp:~vorlon/ubuntu/quantal/python-pam/python3
Reviewer Review Type Date Requested Status
Barry Warsaw (community) Approve
Review via email: mp+107314@code.launchpad.net

Description of the change

python-pam is not maintained upstream or in Debian, so I guess it's up to
us to fix this one.

To post a comment you must log in.
Revision history for this message
Barry Warsaw (barry) wrote :

Steve, this looks good. My only minor thought is the API change in the repr() to always be unicode. I.e. this is a change for the Python 2 version, but since it's just a repr it doesn't bother me. I like Saphhira's additional patch, though with a few changes.

I'll mark this approved, merge yours and Sapphira's into trunk and upload.

Thanks both of you for the patch!

Revision history for this message
Barry Warsaw (barry) :
review: Approve

Unmerged revisions

20. By Steve Langasek

Modernize packaging to dh and debhelper 9.

19. By Steve Langasek

use PyModule_Create instead of Py_InitModule for python3

18. By Steve Langasek

use PyLong_FromLong when building for python3.

17. By Steve Langasek

use PyUnicode_FromString, not PyString_FromString

16. By Steve Langasek

* Port to python3; dead project upstream so not forwarding anywhere.
  - replace 'staticforward' with 'static'.
  - replace ob_type with Py_TYPE(ob).
  - drop tp_getattr function, we just need to set tp_methods instead.
  - fix PyTypeObject definition.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'PAMmodule.c'
2--- PAMmodule.c 2012-03-08 08:06:43 +0000
3+++ PAMmodule.c 2012-05-25 03:33:19 +0000
4@@ -24,7 +24,7 @@
5 PyObject *userData;
6 } PyPAMObject;
7
8-staticforward PyTypeObject PyPAMObject_Type;
9+static PyTypeObject PyPAMObject_Type;
10
11 static void PyPAM_Err(PyPAMObject *self, int result)
12 {
13@@ -107,7 +107,7 @@
14 PyPAMObject *p;
15 struct pam_conv *spc;
16
17- PyPAMObject_Type.ob_type = &PyType_Type;
18+ Py_TYPE(&PyPAMObject_Type) = &PyType_Type;
19 p = (PyPAMObject *) PyObject_NEW(PyPAMObject, &PyPAMObject_Type);
20
21 if ((spc = (struct pam_conv *) malloc(sizeof(struct pam_conv))) == NULL) {
22@@ -490,29 +490,23 @@
23 PyObject_FREE(self);
24 }
25
26-static PyObject * PyPAM_getattr(PyPAMObject *self, char *name)
27-{
28- return Py_FindMethod(PyPAMObject_Methods, (PyObject *) self, name);
29-}
30-
31 static PyObject * PyPAM_repr(PyPAMObject *self)
32 {
33 char buf[1024];
34
35 snprintf(buf, 1024, "<pam object, service=\"%s\", user=\"%s\", conv=%p, pamh=%p>",
36 self->service, self->user, self->conv, self->pamh);
37- return PyString_FromString(buf);
38+ return PyUnicode_FromString(buf);
39 }
40
41 static PyTypeObject PyPAMObject_Type = {
42- PyObject_HEAD_INIT(0) /* Must fill in type value later */
43- 0,
44+ PyVarObject_HEAD_INIT(&PyType_Type, 0) /* Must fill in type value later */
45 "pam",
46 sizeof(PyPAMObject),
47 0,
48 (destructor)PyPAM_dealloc, /*tp_dealloc*/
49 0, /*tp_print*/
50- (getattrfunc)PyPAM_getattr, /*tp_getattr*/
51+ 0, /*tp_getattr*/
52 0, /*tp_setattr*/
53 0, /*tp_compare*/
54 (reprfunc)PyPAM_repr, /*tp_repr*/
55@@ -526,6 +520,16 @@
56 {NULL, NULL, 0, NULL}
57 };
58
59+#if PY_MAJOR_VERSION > 2
60+static struct PyModuleDef PyPAM_Module = {
61+ PyModuleDef_HEAD_INIT,
62+ "PAM", /* name of module */
63+ NULL, /* module documentation */
64+ -1, /* size of per-interpreter state */
65+ PyPAM_Methods
66+};
67+#endif
68+
69 static char PyPAMObject_doc[] = "";
70
71 /* Convenience routine to export an integer value.
72@@ -535,7 +539,11 @@
73 */
74 static void insint(PyObject *d, char *name, int value)
75 {
76+#if PY_MAJOR_VERSION > 2
77+ PyObject *v = PyLong_FromLong((long) value);
78+#else
79 PyObject *v = PyInt_FromLong((long) value);
80+#endif
81
82 if (!v || PyDict_SetItemString(d, name, v))
83 PyErr_Clear();
84@@ -547,7 +555,11 @@
85 {
86 PyObject *m, *d;
87
88+#if PY_MAJOR_VERSION > 2
89+ m = PyModule_Create(&PyPAM_Module);
90+#else
91 m = Py_InitModule("PAM", PyPAM_Methods);
92+#endif
93 d = PyModule_GetDict(m);
94
95 PyPAM_Error = PyErr_NewException("PAM.error", NULL, NULL);
96@@ -555,8 +567,8 @@
97 return;
98 PyDict_SetItemString(d, "error", PyPAM_Error);
99
100- PyPAMObject_Type.ob_type = &PyType_Type;
101 PyPAMObject_Type.tp_doc = PyPAMObject_doc;
102+ PyPAMObject_Type.tp_methods = PyPAMObject_Methods,
103 Py_INCREF(&PyPAMObject_Type);
104
105 insint(d, "PAM_SUCCESS", PAM_SUCCESS);
106
107=== modified file 'debian/changelog'
108--- debian/changelog 2012-03-08 08:06:43 +0000
109+++ debian/changelog 2012-05-25 03:33:19 +0000
110@@ -1,3 +1,17 @@
111+python-pam (0.4.2-12.2ubuntu5) UNRELEASED; urgency=low
112+
113+ * Port to python3; dead project upstream so not forwarding anywhere.
114+ - replace 'staticforward' with 'static'.
115+ - replace ob_type with Py_TYPE(ob).
116+ - drop tp_getattr function, we just need to set tp_methods instead.
117+ - fix PyTypeObject definition.
118+ - use PyUnicode_FromString, not PyString_FromString
119+ - use PyLong_FromLong when building for python3.
120+ - use PyModule_Create instead of Py_InitModule for python3
121+ * Modernize packaging to dh and debhelper 9.
122+
123+ -- Steve Langasek <steve.langasek@ubuntu.com> Thu, 24 May 2012 22:56:26 +0000
124+
125 python-pam (0.4.2-12.2ubuntu4) precise; urgency=low
126
127 * SECURITY UPDATE: possible code execution via double-free (LP: #949218)
128
129=== added file 'debian/compat'
130--- debian/compat 1970-01-01 00:00:00 +0000
131+++ debian/compat 2012-05-25 03:33:19 +0000
132@@ -0,0 +1,1 @@
133+9
134
135=== modified file 'debian/control'
136--- debian/control 2012-03-08 08:06:43 +0000
137+++ debian/control 2012-05-25 03:33:19 +0000
138@@ -1,14 +1,16 @@
139 Source: python-pam
140 Section: python
141 Priority: optional
142-Build-Depends: debhelper (>= 5.0.37.2), python-all-dev (>= 2.3.5-11), python-all-dbg, libpam0g-dev
143+Build-Depends: debhelper (>= 9), python-all-dev (>= 2.3.5-11), python-all-dbg, python3-all-dev, python3-all-dbg, libpam0g-dev
144 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
145 XSBC-Original-Maintainer: Dima Barsky <dima@debian.org>
146-Standards-Version: 3.7.2
147+X-Python-Version: >= 2.6
148+X-Python3-Version: >= 3.2
149+Standards-Version: 3.9.3
150
151 Package: python-pam
152 Architecture: any
153-Depends: ${python:Depends}, ${shlibs:Depends}
154+Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}
155 Conflicts: python2.3-pam, python2.4-pam
156 Replaces: python2.3-pam, python2.4-pam
157 Provides: ${python:Provides}
158@@ -22,10 +24,32 @@
159 Package: python-pam-dbg
160 Priority: extra
161 Architecture: any
162-Depends: python-pam (= ${Source-Version}), python-dbg
163+Depends: python-pam (= ${binary:Version}), python-dbg, ${shlibs:Depends}, ${misc:Depends}
164 Description: A Python interface to the PAM library (debug extension)
165 This module makes the PAM (Pluggable Authentication Modules) functions
166 available in Python. With this module you can write Python applications
167 that implement authentication services using PAM.
168 .
169 This package contains the extension built for the python debug interpreter.
170+
171+Package: python3-pam
172+Architecture: any
173+Depends: ${python3:Depends}, ${shlibs:Depends}, ${misc:Depends}
174+Provides: ${python3:Provides}
175+Suggests: python3-pam-dbg
176+XB-Python-Version: ${python3:Versions}
177+Description: A Python interface to the PAM library
178+ This module makes the PAM (Pluggable Authentication Modules) functions
179+ available in Python 3. With this module you can write Python 3 applications
180+ that implement authentication services using PAM.
181+
182+Package: python3-pam-dbg
183+Priority: extra
184+Architecture: any
185+Depends: python3-pam (= ${binary:Version}), python3-dbg, ${shlibs:Depends}, ${misc:Depends}
186+Description: A Python interface to the PAM library (debug extension)
187+ This module makes the PAM (Pluggable Authentication Modules) functions
188+ available in Python 3. With this module you can write Python 3 applications
189+ that implement authentication services using PAM.
190+ .
191+ This package contains the extension built for the python debug interpreter.
192
193=== added file 'debian/python-pam-dbg.install'
194--- debian/python-pam-dbg.install 1970-01-01 00:00:00 +0000
195+++ debian/python-pam-dbg.install 2012-05-25 03:33:19 +0000
196@@ -0,0 +1,1 @@
197+usr/lib/python2*/dist-packages/*_d.so
198
199=== added file 'debian/python-pam.examples'
200--- debian/python-pam.examples 1970-01-01 00:00:00 +0000
201+++ debian/python-pam.examples 2012-05-25 03:33:19 +0000
202@@ -0,0 +1,1 @@
203+examples/*
204
205=== added file 'debian/python-pam.install'
206--- debian/python-pam.install 1970-01-01 00:00:00 +0000
207+++ debian/python-pam.install 2012-05-25 03:33:19 +0000
208@@ -0,0 +1,2 @@
209+usr/lib/python2*/dist-packages/*[!_][!_].so
210+usr/lib/python2*/dist-packages/*.egg-info
211
212=== added file 'debian/python3-pam-dbg.install'
213--- debian/python3-pam-dbg.install 1970-01-01 00:00:00 +0000
214+++ debian/python3-pam-dbg.install 2012-05-25 03:33:19 +0000
215@@ -0,0 +1,1 @@
216+usr/lib/python3/dist-packages/*-[0-9][0-9]d*.so
217
218=== added file 'debian/python3-pam.examples'
219--- debian/python3-pam.examples 1970-01-01 00:00:00 +0000
220+++ debian/python3-pam.examples 2012-05-25 03:33:19 +0000
221@@ -0,0 +1,1 @@
222+examples/*
223
224=== added file 'debian/python3-pam.install'
225--- debian/python3-pam.install 1970-01-01 00:00:00 +0000
226+++ debian/python3-pam.install 2012-05-25 03:33:19 +0000
227@@ -0,0 +1,2 @@
228+usr/lib/python3/dist-packages/*-[0-9][0-9][!d]*.so
229+usr/lib/python3/dist-packages/*.egg-info
230
231=== modified file 'debian/rules'
232--- debian/rules 2010-11-24 16:06:15 +0000
233+++ debian/rules 2012-05-25 03:33:19 +0000
234@@ -2,67 +2,37 @@
235 # Uncomment this to turn on verbose mode.
236 #export DH_VERBOSE=1
237
238-# This is the debhelper compatibility version to use.
239-export DH_COMPAT=5
240-
241-PYVERS=$(shell pyversions -r)
242-
243--include /usr/share/python/python.mk
244-
245-build: build-stamp
246-build-stamp:
247- dh_testdir
248- set -e; \
249- for python in $(PYVERS); do \
250- $$python setup.py build; \
251- $$python-dbg setup.py build; \
252- done
253- touch build-stamp
254-
255-clean:
256- dh_testdir
257- set -e; \
258- for python in $(PYVERS); do \
259- $$python setup.py clean; \
260- $$python-dbg setup.py clean; \
261- done
262- rm -rf build-stamp build
263- dh_clean
264-
265-install: build
266- dh_testdir
267- dh_testroot
268- dh_clean -k
269- dh_installdirs
270-
271- set -e; \
272- for python in $(PYVERS); do \
273- $$python setup.py install --root=debian/python-pam --install-layout=deb; \
274- $$python-dbg setup.py install --root=debian/python-pam-dbg --install-layout=deb; \
275- done
276- find debian/python-pam-dbg ! -type d ! -name '*_d.so' | xargs rm -f
277-
278-# Build architecture-independent files here.
279-binary-indep: build install
280-
281-# Build architecture-dependent files here.
282-binary-arch: build install
283- dh_testdir
284- dh_testroot
285- dh_installdocs -a AUTHORS README
286- dh_installexamples -a examples/*
287- dh_installchangelogs -a ChangeLog
288+PYTHON2=$(shell pyversions -vr)
289+PYTHON3=$(shell py3versions -vr)
290+
291+%:
292+ dh $@ --with python2,python3
293+
294+build-python%:
295+ python$* setup.py build
296+ python$*-dbg setup.py build
297+
298+override_dh_auto_build: $(PYTHON3:%=build-python%)
299+ dh_auto_build
300+
301+install-python%:
302+ python$* setup.py install --root=$(CURDIR)/debian/tmp --install-layout=deb
303+ python$*-dbg setup.py install --root=$(CURDIR)/debian/tmp --install-layout=deb
304+
305+override_dh_auto_install: $(PYTHON3:%=install-python%)
306+ dh_auto_install
307+
308+override_dh_auto_clean:
309+ dh_auto_clean
310+ rm -rf build
311+ rm -rf *.egg-info
312+
313+override_dh_installdocs:
314+ dh_installdocs AUTHORS README
315+
316+override_dh_installchangelogs:
317+ dh_installchangelogs ChangeLog
318 rm -rf debian/python-pam-dbg/usr/share/doc/python-pam-dbg
319 ln -sf python-pam debian/python-pam-dbg/usr/share/doc/python-pam-dbg
320- dh_strip -a -Npython-pam-dbg --dbg-package=python-pam-dbg
321- dh_compress -a
322- dh_fixperms -a
323- dh_python2 -a
324- dh_installdeb -a
325- dh_shlibdeps -a
326- dh_gencontrol -a
327- dh_md5sums -a
328- dh_builddeb -a
329-
330-binary: binary-indep binary-arch
331-.PHONY: build clean binary-indep binary-arch binary
332+ rm -rf debian/python3-pam-dbg/usr/share/doc/python3-pam-dbg
333+ ln -sf python3-pam debian/python3-pam-dbg/usr/share/doc/python3-pam-dbg

Subscribers

People subscribed via source and target branches