diff -Nru python-cups-1.9.58/ChangeLog python-cups-1.9.59/ChangeLog --- python-cups-1.9.58/ChangeLog 2011-07-26 13:20:12.000000000 +0200 +++ python-cups-1.9.59/ChangeLog 2011-10-03 18:23:22.000000000 +0200 @@ -1,3 +1,14 @@ +2011-10-03 Tim Waugh + + * setup.py: Version 1.9.59. + +2011-10-03 Tim Waugh + + * cupsmodule.c (do_password_callback), cupsconnection.c + (password_callback): Return NULL instead of the empty string + when handling an exception or when the callback returned an + empty string, and handle the callback returning None. + 2011-07-26 Tim Waugh * setup.py: Version 1.9.58. diff -Nru python-cups-1.9.58/cupsconnection.c python-cups-1.9.59/cupsconnection.c --- python-cups-1.9.58/cupsconnection.c 2011-07-19 10:42:10.000000000 +0200 +++ python-cups-1.9.59/cupsconnection.c 2011-10-03 18:13:58.000000000 +0200 @@ -366,20 +366,26 @@ Py_DECREF (args); if (result == NULL) { - debugprintf ("<- password_callback (empty string)\n"); + debugprintf ("<- password_callback (exception)\n"); Connection_begin_allow_threads (self); - return ""; + return NULL; } - pwval = PyString_AsString (result); free (self->cb_password); - self->cb_password = strdup (pwval); + if (result == Py_None) + self->cb_password = NULL; + else + { + pwval = PyString_AsString (result); + self->cb_password = strdup (pwval); + } + Py_DECREF (result); - if (!self->cb_password) + if (!self->cb_password || !*self->cb_password) { - debugprintf ("<- password_callback (empty string)\n"); + debugprintf ("<- password_callback (empty/null)\n"); Connection_begin_allow_threads (self); - return ""; + return NULL; } Connection_begin_allow_threads (self); diff -Nru python-cups-1.9.58/cupsmodule.c python-cups-1.9.59/cupsmodule.c --- python-cups-1.9.58/cupsmodule.c 2011-05-24 12:01:42.000000000 +0200 +++ python-cups-1.9.59/cupsmodule.c 2011-10-03 18:16:52.000000000 +0200 @@ -156,9 +156,9 @@ Py_DECREF (args); if (result == NULL) { - debugprintf ("<- do_password_callback (empty string)\n"); + debugprintf ("<- do_password_callback (exception)\n"); Connection_begin_allow_threads (tls->g_current_connection); - return ""; + return NULL; } if (password) { @@ -166,14 +166,20 @@ password = NULL; } - pwval = PyString_AsString (result); - password = strdup (pwval); + if (result == Py_None) + password = NULL; + else + { + pwval = PyString_AsString (result); + password = strdup (pwval); + } + Py_DECREF (result); - if (!password) + if (!password || !*password) { - debugprintf ("<- do_password_callback (empty string)\n"); + debugprintf ("<- do_password_callback (empty/null)\n"); Connection_begin_allow_threads (tls->g_current_connection); - return ""; + return NULL; } Connection_begin_allow_threads (tls->g_current_connection); @@ -513,8 +519,8 @@ "setPasswordCB(fn) -> None\n\n" "Set password callback function. This Python function will be called \n" "when a password is required. It must take one string parameter \n" - "(the password prompt) and it must return a string (the password). To \n" - "abort the operation it may return the empty string ('').\n\n" + "(the password prompt) and it must return a string (the password), or \n" + "None to abort the operation.\n\n" "@type fn: callable object\n" "@param fn: callback function" }, @@ -523,10 +529,10 @@ "setPasswordCB2(fn, context=None) -> None\n\n" "Set password callback function. This Python function will be called \n" "when a password is required. It must take parameters of type string \n" - "(the password prompt), instance (the cups.Connection), string (the HTTP " - "method), string (the HTTP resource) and, optionally, the user-supplied " - "context. It must return a string (the password). To \n" - "abort the operation it may return the empty string ('').\n\n" + "(the password prompt), instance (the cups.Connection), string (the \n" + "HTTP method), string (the HTTP resource) and, optionally, the user-\n" + "supplied context. It must return a string (the password), or None \n" + "to abort the operation.\n\n" "@type fn: callable object, or None for default handler\n" "@param fn: callback function" }, #endif /* HAVE_CUPS_1_4 */ diff -Nru python-cups-1.9.58/debian/changelog python-cups-1.9.59/debian/changelog --- python-cups-1.9.58/debian/changelog 2011-10-08 22:33:16.000000000 +0200 +++ python-cups-1.9.59/debian/changelog 2011-10-08 22:33:16.000000000 +0200 @@ -1,3 +1,13 @@ +python-cups (1.9.59-0ubuntu0.1) oneiric-proposed; urgency=low + + * New upstream bug fix release + o CUPS password callback: Return NULL instead of the empty string when + handling an exception or when the callback returned an empty string, + and handle the callback returning None. This avoids infinite password + dialog loops (LP: #653132). + + -- Till Kamppeter Tue, 04 Oct 2011 15:58:18 +0200 + python-cups (1.9.58-0ubuntu1) oneiric; urgency=low * New upstream release diff -Nru python-cups-1.9.58/Makefile python-cups-1.9.59/Makefile --- python-cups-1.9.58/Makefile 2011-07-26 13:28:36.000000000 +0200 +++ python-cups-1.9.59/Makefile 2011-08-04 13:33:15.000000000 +0200 @@ -13,7 +13,7 @@ cups.so: force python setup.py build - mv build/lib*/$@ . + ln -sf build/lib*/$@ . doc: cups.so rm -rf html diff -Nru python-cups-1.9.58/NEWS python-cups-1.9.59/NEWS --- python-cups-1.9.58/NEWS 2011-07-19 10:42:45.000000000 +0200 +++ python-cups-1.9.59/NEWS 2011-10-03 18:23:08.000000000 +0200 @@ -1,6 +1,11 @@ NEWS ---- +New in 1.9.59: + +* Password callbacks can now return None to indicate they want to + abort the current operation. + New in 1.9.58: * cups.Connection.adminExportSamba diff -Nru python-cups-1.9.58/PKG-INFO python-cups-1.9.59/PKG-INFO --- python-cups-1.9.58/PKG-INFO 2011-07-26 13:29:19.000000000 +0200 +++ python-cups-1.9.59/PKG-INFO 2011-10-03 18:32:45.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: pycups -Version: 1.9.58 +Version: 1.9.59 Summary: Python bindings for libcups Home-page: http://cyberelk.net/tim/software/pycups/ Author: Tim Waugh diff -Nru python-cups-1.9.58/setup.py python-cups-1.9.59/setup.py --- python-cups-1.9.58/setup.py 2011-07-26 13:23:35.000000000 +0200 +++ python-cups-1.9.59/setup.py 2011-10-03 18:22:41.000000000 +0200 @@ -35,7 +35,7 @@ from distutils.core import setup, Extension import sys -VERSION="1.9.58" +VERSION="1.9.59" libraries=["cups"] if sys.platform == "darwin":