From f4426a2d401c3a44d57d4f68308badfa0d0482b0 Mon Sep 17 00:00:00 2001
From: eabdullin <ed.abdullin.1@gmail.com>
Date: Tue, 18 Mar 2025 02:40:15 +0000
Subject: [PATCH] import UBI cups-filters-1.28.7-18.el9_5.1

---
 ...enerate-PPD-for-remote-raw-queues-44.patch | 51 +++++++++++++++++++
 SPECS/cups-filters.spec                       |  7 ++-
 2 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100644 SOURCES/0001-Do-not-generate-PPD-for-remote-raw-queues-44.patch

diff --git a/SOURCES/0001-Do-not-generate-PPD-for-remote-raw-queues-44.patch b/SOURCES/0001-Do-not-generate-PPD-for-remote-raw-queues-44.patch
new file mode 100644
index 0000000..76476e9
--- /dev/null
+++ b/SOURCES/0001-Do-not-generate-PPD-for-remote-raw-queues-44.patch
@@ -0,0 +1,51 @@
+diff --git a/utils/cups-browsed.c b/utils/cups-browsed.c
+index a5e5779..b190829 100644
+--- a/utils/cups-browsed.c
++++ b/utils/cups-browsed.c
+@@ -7271,8 +7271,14 @@ create_remote_printer_entry (const char *queue_name,
+       p->prattrs = get_printer_attributes(p->uri, NULL, 0, NULL, 0, 1);
+       debug_log_out(get_printer_attributes_log);
+       if (p->prattrs == NULL)
++      {
+ 	debug_printf("get-printer-attributes IPP call failed on printer %s (%s).\n",
+ 		     p->queue_name, p->uri);
++	goto fail;
++      }
++
++      attr = ippFindAttribute(p->prattrs, "printer-make-and-model", IPP_TAG_TEXT);
++      p->make_model = attr ? strdup(ippGetString(attr, 0, NULL)) : NULL;
+     }
+   } else {
+ #ifndef HAVE_CUPS_1_6
+@@ -8242,7 +8248,8 @@ gboolean update_cups_queues(gpointer unused) {
+ 	    debug_printf("Generated Default Attributes for local queue %s\n",
+ 			 p->queue_name);
+ 	  }
+-	  if (ppdfile == NULL) {
++	  if (ppdfile == NULL && make_model && strcmp(make_model, "Local Raw Printer"))
++	  {
+ 	    /* If we do not want CUPS-generated PPDs or we cannot obtain a
+ 	       CUPS-generated PPD, for example if CUPS does not create a 
+ 	       temporary queue for this printer, we generate a PPD by
+@@ -8580,7 +8587,8 @@ gboolean update_cups_queues(gpointer unused) {
+ 	    debug_printf("Generated Default Attributes for local queue %s\n",
+ 			 p->queue_name);
+ 	  }
+-	  if (ppdfile == NULL) {
++	  if (ppdfile == NULL && make_model && strcmp(make_model, "Local Raw Printer"))
++	  {
+ 	    /* If we do not want CUPS-generated PPDs or we cannot obtain a
+ 	       CUPS-generated PPD, for example if CUPS does not create a
+ 	       temporary queue for this printer, we generate a PPD by
+@@ -8793,6 +8801,11 @@ gboolean update_cups_queues(gpointer unused) {
+         }
+ 	ppdfile = strdup(buf);
+       }
++      else
++      {
++	// No PPD - define nickname as make_model for remote raw queue
++	p->nickname = p->make_model ? strdup(p->make_model) : strdup("Local Raw Printer");
++      }
+ 
+       /* Create a new CUPS queue or modify the existing queue */
+       request = ippNewRequest(CUPS_ADD_MODIFY_PRINTER);
diff --git a/SPECS/cups-filters.spec b/SPECS/cups-filters.spec
index ddb3dd3..4885ef5 100644
--- a/SPECS/cups-filters.spec
+++ b/SPECS/cups-filters.spec
@@ -11,7 +11,7 @@
 Summary: OpenPrinting CUPS filters and backends
 Name:    cups-filters
 Version: 1.28.7
-Release: 18%{?dist}
+Release: 18%{?dist}.1
 
 # For a breakdown of the licensing, see COPYING file
 # GPLv2:   filters: commandto*, imagetoraster, pdftops, rasterto*,
@@ -48,6 +48,8 @@ Patch06: browsed-ignore-NULL-attrs.patch
 Patch07: cups-filters-CVE-2024-47175.patch
 # CVE-2024-47076 cups-filters: `cfGetPrinterAttributes` API does not perform sanitization on returned IPP attributes
 Patch08: 0001-cfGetPrinterAttributes5-Validate-response-attributes.patch
+# RHEL-78978 [cups-browsed] Prints to remote RAW queues are converted to PDF documents
+Patch09: 0001-Do-not-generate-PPD-for-remote-raw-queues-44.patch
 
 
 # autogen.sh
@@ -454,6 +456,9 @@ fi
 %endif
 
 %changelog
+* Tue Feb 18 2025 Zdenek Dohnal <zdohnal@redhat.com> - 1.28.7-18.1
+- RHEL-78978 [cups-browsed] Prints to remote RAW queues are converted to PDF documents
+
 * Tue Oct 01 2024 Zdenek Dohnal <zdohnal@redhat.com> - 1.28.7-18
 - CVE-2024-47175 cups-filters: remote command injection via attacker controlled data in PPD file
 - CVE-2024-47076 cups-filters: `cfGetPrinterAttributes` API does not perform sanitization on returned IPP attributes