background thread for add IPP Everywhere printers permanently didn't resolve mDNS

This commit is contained in:
Zdenek Dohnal 2022-03-04 08:30:39 +01:00
parent b420fbd947
commit fac50285ae
2 changed files with 43 additions and 1 deletions

31
cups-resolve-uri.patch Normal file
View File

@ -0,0 +1,31 @@
diff -up cups-2.4.1/scheduler/ipp.c.resolve-uri cups-2.4.1/scheduler/ipp.c
--- cups-2.4.1/scheduler/ipp.c.resolve-uri 2022-03-04 08:13:13.712346134 +0100
+++ cups-2.4.1/scheduler/ipp.c 2022-03-04 08:17:17.486819820 +0100
@@ -5271,6 +5271,7 @@ create_local_bg_thread(
userpass[256], /* User:pass */
host[256], /* Hostname */
resource[1024], /* Resource path */
+ uri[1024], /* Resolved URI, if needed */
line[1024]; /* Line from PPD */
int port; /* Port number */
http_encryption_t encryption; /* Type of encryption to use */
@@ -5292,6 +5293,19 @@ create_local_bg_thread(
cupsdLogMessage(CUPSD_LOG_DEBUG, "%s: Generating PPD file from \"%s\"...", printer->name, printer->device_uri);
+ if (strstr(printer->device_uri, "._tcp"))
+ {
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "%s: Resolving mDNS URI \"%s\".", printer->name, printer->device_uri);
+
+ if (!_httpResolveURI(printer->device_uri, uri, sizeof(uri), _HTTP_RESOLVE_DEFAULT, NULL, NULL))
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR, "%s: Couldn't resolve mDNS URI \"%s\".", printer->name, printer->device_uri);
+ return (NULL);
+ }
+
+ printer->device_uri = uri;
+ }
+
if (httpSeparateURI(HTTP_URI_CODING_ALL, printer->device_uri, scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
{
cupsdLogMessage(CUPSD_LOG_ERROR, "%s: Bad device URI \"%s\".", printer->name, printer->device_uri);

View File

@ -15,7 +15,7 @@ Summary: CUPS printing system
Name: cups
Epoch: 1
Version: 2.4.1
Release: 4%{?dist}
Release: 5%{?dist}
License: ASL 2.0
Url: https://openprinting.github.io/cups/
# Apple stopped uploading the new versions into github, use OpenPrinting fork
@ -70,6 +70,10 @@ Patch100: cups-lspp.patch
# uninitialized value in cups library on ppc64le
# https://github.com/OpenPrinting/cups/pull/329
Patch1000: 0001-cups-fix-uninit-value-jump.patch
# background thread for adding IPP Everywhere printers didn't resolve
# mDNS URIs
# https://github.com/OpenPrinting/cups/issues/340
Patch1001: cups-resolve-uri.patch
##### Patches removed because IMHO they aren't no longer needed
##### but still I'll leave them in git in case their removal
@ -274,6 +278,10 @@ to CUPS daemon. This solution will substitute printer drivers and raw queues in
# UPSTREAM PATCHES
# uninitialized value in PPD CUPS API
%patch1000 -p1 -b .ppd-memleak
# background thread for adding IPP Everywhere printers didn't resolve
# mDNS URIs
# https://github.com/OpenPrinting/cups/issues/340
%patch1001 -p1 -b .resolve-uri
%if %{lspp}
@ -657,6 +665,9 @@ rm -f %{cups_serverbin}/backend/smb
%{_mandir}/man7/ippeveps.7.gz
%changelog
* Wed Mar 02 2022 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.4.1-5
- background thread for add IPP Everywhere printers permanently didn't resolve mDNS
* Thu Feb 24 2022 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.4.1-4
- jump based on uninitialized value in PPD related CUPS API on ppc64le