system-config-printer/pycups-git.patch

114 lines
3.8 KiB
Diff
Raw Normal View History

diff -U0 pycups-1.9.44/ChangeLog.pycups-git pycups-1.9.44/ChangeLog
--- pycups-1.9.44/ChangeLog.pycups-git 2008-11-28 12:27:15.000000000 +0000
+++ pycups-1.9.44/ChangeLog 2008-12-17 16:36:03.000000000 +0000
@@ -0,0 +1,16 @@
+2008-12-17 Tim Waugh <twaugh@redhat.com>
+
+ * cupsconnection.c (Connection_printTestPage): Look for
+ "testprint" as well as "testprint.ps", as that is the name of the
+ test page file in CUPS 1.4 (bug #476612).
+
+2008-12-17 Tim Waugh <twaugh@redhat.com>
+
+ * cupsconnection.c (Connection_printTestPage): Only set a
+ document-format attribute if one is specified.
+
+2008-12-17 Tim Waugh <twaugh@redhat.com>
+
+ * cupsconnection.c (Connection_printTestPage): Avoid crash when
+ given bad parameters.
+
diff -up pycups-1.9.44/cupsconnection.c.pycups-git pycups-1.9.44/cupsconnection.c
--- pycups-1.9.44/cupsconnection.c.pycups-git 2008-11-25 12:12:38.000000000 +0000
+++ pycups-1.9.44/cupsconnection.c 2008-12-17 16:36:03.000000000 +0000
@@ -2908,13 +2908,13 @@ Connection_printTestPage (Connection *se
PyObject *printerobj;
char *printer;
PyObject *fileobj = NULL;
- char *file;
+ char *file = NULL;
PyObject *titleobj = NULL;
- char *title;
+ char *title = NULL;
PyObject *formatobj = NULL;
- char *format;
+ char *format = NULL;
PyObject *userobj = NULL;
- char *user;
+ char *user = NULL;
const char *datadir;
char filename[PATH_MAX];
char uri[HTTP_MAX_URI];
@@ -2946,17 +2946,33 @@ Connection_printTestPage (Connection *se
}
if (!fileobj) {
- const char *testprint = "%s/data/testprint.ps";
- if ((datadir = getenv ("CUPS_DATADIR")) != NULL)
- snprintf (filename, sizeof (filename), testprint, datadir);
- else {
+ const char *testprint[] = { "%s/data/testprint",
+ "%s/data/testprint.ps",
+ NULL };
+ if ((datadir = getenv ("CUPS_DATADIR")) != NULL) {
+ const char **pattern;
+ for (pattern = testprint; *pattern != NULL; pattern++) {
+ snprintf (filename, sizeof (filename), *pattern, datadir);
+ if (access (filename, R_OK) == 0)
+ break;
+ }
+ } else {
const char *const dirs[] = { "/usr/share/cups",
"/usr/local/share/cups",
NULL };
+ int found = 0;
int i;
for (i = 0; (datadir = dirs[i]) != NULL; i++) {
- snprintf (filename, sizeof (filename), testprint, datadir);
- if (access (filename, R_OK) == 0)
+ const char **pattern;
+ for (pattern = testprint; *pattern != NULL; pattern++) {
+ snprintf (filename, sizeof (filename), *pattern, datadir);
+ if (access (filename, R_OK) == 0) {
+ found = 1;
+ break;
+ }
+ }
+
+ if (found)
break;
}
@@ -2966,7 +2982,7 @@ Connection_printTestPage (Connection *se
* client-error-not-found, but we'll let that happen rather
* than raising an exception so as to be consistent with the
* case where CUPS_DATADIR is set and we trust it. */
- snprintf (filename, sizeof (filename), testprint, dirs[0]);
+ snprintf (filename, sizeof (filename), testprint[0], dirs[0]);
}
file = filename;
@@ -2975,9 +2991,6 @@ Connection_printTestPage (Connection *se
if (!titleobj)
title = "Test Page";
- if (!formatobj)
- format = "application/postscript";
-
if (!userobj)
user = (char *) cupsUser();
@@ -2991,8 +3004,10 @@ Connection_printTestPage (Connection *se
"requesting-user-name", NULL, user);
ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name",
NULL, title);
- ippAddString (request, IPP_TAG_JOB, IPP_TAG_MIMETYPE, "document-format",
- NULL, format);
+ if (format)
+ ippAddString (request, IPP_TAG_JOB, IPP_TAG_MIMETYPE, "document-format",
+ NULL, format);
+
Connection_begin_allow_threads (self);
answer = cupsDoFileRequest (self->http, request, resource, file);
Connection_end_allow_threads (self);