From 16b4c36068d43527925026f2f02701023b5a9c89 Mon Sep 17 00:00:00 2001 From: Till Kamppeter Date: Tue, 3 Sep 2019 15:14:58 +0200 Subject: cups-browsed: Do not cause fatal error on left over queues of a previous session. cups-browsed: If a locally generated queue (usually with "implicitclass://..." URI) left over from a previous (crashed) session is picked up on startup, do not set the URI as the remote printer's URI and do not cause a fatal error on a failed get-printer-attributes IPP request (Issue #148). Closes-Debian: #939316 --- utils/cups-browsed.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/utils/cups-browsed.c b/utils/cups-browsed.c index c828bd1c4..ddddbe0d2 100644 --- a/utils/cups-browsed.c +++ b/utils/cups-browsed.c @@ -6908,12 +6908,12 @@ create_remote_printer_entry (const char *queue_name, remote CUPS server gets used. So we will not generate a PPD file or interface script at this point. */ p->netprinter = 0; - p->prattrs = get_printer_attributes(p->uri); p->nickname = NULL; - if (p->prattrs == NULL) { - debug_printf("get-printer-attributes IPP call failed on printer %s (%s).\n", - p->queue_name, p->uri); - goto fail; + if (p->uri[0] != '\0') { + p->prattrs = get_printer_attributes(p->uri); + if (p->prattrs == NULL) + debug_printf("get-printer-attributes IPP call failed on printer %s (%s).\n", + p->queue_name, p->uri); } } else { #ifndef HAVE_CUPS_1_6 @@ -9133,9 +9133,19 @@ examine_discovered_printer_record(const char *host, discovered through the loopback interface (preferred interface) */ ipp_discovery_t *ippdis = cupsArrayFirst(p->ipp_discoveries); + /* Force upgrade if the found entry is marked unconfirmed or + disappeared */ + if (p->status == STATUS_UNCONFIRMED || + p->status == STATUS_DISAPPEARED) { + upgrade = 1; + debug_printf("Replacing printer entry %s (Host: %s, Port: %d) as it was marked %s. New URI: %s\n", + p->queue_name, remote_host, port, + (p->status == STATUS_UNCONFIRMED ? "unconfirmed" : + "disappeared"), + uri); /* Check if there is a downgrade */ /* IPPS -> IPP */ - if ((ptr = strcasestr(type, "_ipp")) != NULL && + } else if ((ptr = strcasestr(type, "_ipp")) != NULL && *(ptr + 4) != 's' && !strncasecmp(p->uri, "ipps:", 5)) { downgrade = 1; @@ -11468,7 +11478,7 @@ find_previous_queue (gpointer key, debug_printf("find_previous_queue() in THREAD %ld\n", pthread_self()); if (printer->cups_browsed_controlled) { /* Queue found, add to our list */ - p = create_remote_printer_entry (name, "", "", printer->device_uri, "", "", + p = create_remote_printer_entry (name, "", "", "", "", "", 0, "", "", "", "", 0, NULL, 0, 0, NULL, -1); if (p) { @@ -11484,10 +11494,9 @@ find_previous_queue (gpointer key, p->slave_of = NULL; debug_printf("Found CUPS queue %s (URI: %s) from previous session.\n", p->queue_name, p->uri); - } else { - debug_printf("ERROR: Unable to allocate memory.\n"); - exit(1); - } + } else + debug_printf("ERROR: Unable to create print queue entry for prrinter of previous session: %s (%s).\n", + name, printer->device_uri); } } -- cgit v1.2.3 From 5115e5eab5ccfa97ff6f74a3a79ed3de577cacd9 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Wed, 4 Sep 2019 08:24:36 +0200 Subject: cups-filters 1.25.4-2 Debian release --- debian/changelog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/debian/changelog b/debian/changelog index e484b2390..fd438cdbe 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +cups-filters (1.25.4-2) unstable; urgency=medium + + * Backport upstream patch: + - cups-browsed: Do not cause fatal error on left over queues of a previous + session (Closes: #939316) + + -- Didier Raboud Wed, 04 Sep 2019 08:24:36 +0200 + cups-filters (1.25.4-1) unstable; urgency=medium * New upstream version 1.25.4 -- cgit v1.2.3 From 293b7d45456b2fd47e17673ee641f34e0687013f Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Wed, 4 Sep 2019 08:25:25 +0200 Subject: Commit patch queue (exported by git-debrebase) [git-debrebase make-patches: export and commit patches] --- ...d-Do-not-cause-fatal-error-on-left-over-q.patch | 83 ++++++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 84 insertions(+) create mode 100644 debian/patches/0001-cups-browsed-Do-not-cause-fatal-error-on-left-over-q.patch create mode 100644 debian/patches/series diff --git a/debian/patches/0001-cups-browsed-Do-not-cause-fatal-error-on-left-over-q.patch b/debian/patches/0001-cups-browsed-Do-not-cause-fatal-error-on-left-over-q.patch new file mode 100644 index 000000000..dc11f489f --- /dev/null +++ b/debian/patches/0001-cups-browsed-Do-not-cause-fatal-error-on-left-over-q.patch @@ -0,0 +1,83 @@ +From: Till Kamppeter +Date: Tue, 3 Sep 2019 15:14:58 +0200 +Subject: cups-browsed: Do not cause fatal error on left over queues of a + previous session. + + cups-browsed: If a locally generated queue (usually with + "implicitclass://..." URI) left over from a previous + (crashed) session is picked up on startup, do not set the + URI as the remote printer's URI and do not cause a fatal + error on a failed get-printer-attributes IPP request (Issue + #148). + +Closes-Debian: #939316 +--- + utils/cups-browsed.c | 31 ++++++++++++++++++++----------- + 1 file changed, 20 insertions(+), 11 deletions(-) + +diff --git a/utils/cups-browsed.c b/utils/cups-browsed.c +index c828bd1..ddddbe0 100644 +--- a/utils/cups-browsed.c ++++ b/utils/cups-browsed.c +@@ -6908,12 +6908,12 @@ create_remote_printer_entry (const char *queue_name, + remote CUPS server gets used. So we will not generate a PPD file + or interface script at this point. */ + p->netprinter = 0; +- p->prattrs = get_printer_attributes(p->uri); + p->nickname = NULL; +- if (p->prattrs == NULL) { +- debug_printf("get-printer-attributes IPP call failed on printer %s (%s).\n", +- p->queue_name, p->uri); +- goto fail; ++ if (p->uri[0] != '\0') { ++ p->prattrs = get_printer_attributes(p->uri); ++ if (p->prattrs == NULL) ++ debug_printf("get-printer-attributes IPP call failed on printer %s (%s).\n", ++ p->queue_name, p->uri); + } + } else { + #ifndef HAVE_CUPS_1_6 +@@ -9133,9 +9133,19 @@ examine_discovered_printer_record(const char *host, + discovered through the loopback interface (preferred interface) */ + ipp_discovery_t *ippdis = cupsArrayFirst(p->ipp_discoveries); + ++ /* Force upgrade if the found entry is marked unconfirmed or ++ disappeared */ ++ if (p->status == STATUS_UNCONFIRMED || ++ p->status == STATUS_DISAPPEARED) { ++ upgrade = 1; ++ debug_printf("Replacing printer entry %s (Host: %s, Port: %d) as it was marked %s. New URI: %s\n", ++ p->queue_name, remote_host, port, ++ (p->status == STATUS_UNCONFIRMED ? "unconfirmed" : ++ "disappeared"), ++ uri); + /* Check if there is a downgrade */ + /* IPPS -> IPP */ +- if ((ptr = strcasestr(type, "_ipp")) != NULL && ++ } else if ((ptr = strcasestr(type, "_ipp")) != NULL && + *(ptr + 4) != 's' && + !strncasecmp(p->uri, "ipps:", 5)) { + downgrade = 1; +@@ -11468,7 +11478,7 @@ find_previous_queue (gpointer key, + debug_printf("find_previous_queue() in THREAD %ld\n", pthread_self()); + if (printer->cups_browsed_controlled) { + /* Queue found, add to our list */ +- p = create_remote_printer_entry (name, "", "", printer->device_uri, "", "", ++ p = create_remote_printer_entry (name, "", "", "", "", "", + 0, "", "", "", "", 0, NULL, 0, 0, NULL, + -1); + if (p) { +@@ -11484,10 +11494,9 @@ find_previous_queue (gpointer key, + p->slave_of = NULL; + debug_printf("Found CUPS queue %s (URI: %s) from previous session.\n", + p->queue_name, p->uri); +- } else { +- debug_printf("ERROR: Unable to allocate memory.\n"); +- exit(1); +- } ++ } else ++ debug_printf("ERROR: Unable to create print queue entry for prrinter of previous session: %s (%s).\n", ++ name, printer->device_uri); + } + } + diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 000000000..6366606e2 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +0001-cups-browsed-Do-not-cause-fatal-error-on-left-over-q.patch -- cgit v1.2.3