[cups] Use IP address when resolving DNSSD URIs (bug #948288).

Tim Waugh twaugh at fedoraproject.org
Thu Apr 4 14:55:45 UTC 2013


commit 55c9869389aa64c6a085593755641563edcc678d
Author: Tim Waugh <twaugh at redhat.com>
Date:   Thu Apr 4 15:50:25 2013 +0100

    Use IP address when resolving DNSSD URIs (bug #948288).

 cups-avahi-address.patch |   75 ++++++++++++++++++++++++++++++++++++++++++++++
 cups.spec                |    8 ++++-
 2 files changed, 82 insertions(+), 1 deletions(-)
---
diff --git a/cups-avahi-address.patch b/cups-avahi-address.patch
new file mode 100644
index 0000000..a03d1ad
--- /dev/null
+++ b/cups-avahi-address.patch
@@ -0,0 +1,75 @@
+diff -up cups-1.6.2/cups/http-support.c.avahi-address cups-1.6.2/cups/http-support.c
+--- cups-1.6.2/cups/http-support.c.avahi-address	2013-03-11 18:44:36.000000000 +0000
++++ cups-1.6.2/cups/http-support.c	2013-04-04 15:39:06.651847041 +0100
+@@ -2121,7 +2121,7 @@ http_resolve_cb(
+     const char             *type,	/* I - Registration type */
+     const char             *domain,	/* I - Domain (unused) */
+     const char             *hostTarget,	/* I - Hostname */
+-    const AvahiAddress     *address,	/* I - Address (unused) */
++    const AvahiAddress     *address,	/* I - Address */
+     uint16_t               port,	/* I - Port number */
+     AvahiStringList        *txt,	/* I - TXT record */
+     AvahiLookupResultFlags flags,	/* I - Lookup flags (unused) */
+@@ -2253,36 +2253,37 @@ http_resolve_cb(
+ 
+     DEBUG_printf(("8http_resolve_cb: Looking up \"%s\".", hostTarget));
+ 
+-    snprintf(fqdn, sizeof(fqdn), "%d", ntohs(port));
+-    if ((addrlist = httpAddrGetList(hostTarget, AF_UNSPEC, fqdn)) != NULL)
++    int error = getnameinfo(&(address->data),
++			    address->proto == AVAHI_PROTO_INET ?
++			    sizeof (AvahiIPv4Address) :
++			    (address->proto == AVAHI_PROTO_INET6 ?
++			     sizeof (AvahiIPv6Address) :
++			     sizeof (address->data)),
++			    fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD);
++
++    if (!error)
+     {
+-      for (addr = addrlist; addr; addr = addr->next)
++      DEBUG_printf(("8http_resolve_cb: Found \"%s\".", fqdn));
++
++      if ((hostptr = fqdn + strlen(fqdn) - 6) <= fqdn ||
++	  _cups_strcasecmp(hostptr, ".local"))
+       {
+-        int error = getnameinfo(&(addr->addr.addr),
+-	                        httpAddrLength(&(addr->addr)),
+-			        fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD);
+-
+-        if (!error)
+-	{
+-	  DEBUG_printf(("8http_resolve_cb: Found \"%s\".", fqdn));
+-
+-	  if ((hostptr = fqdn + strlen(fqdn) - 6) <= fqdn ||
+-	      _cups_strcasecmp(hostptr, ".local"))
+-	  {
+-	    hostTarget = fqdn;
+-	    break;
+-	  }
+-	}
++	hostTarget = fqdn;
++      }
++    }
+ #ifdef DEBUG
+-	else
+-	  DEBUG_printf(("8http_resolve_cb: \"%s\" did not resolve: %d",
+-	                httpAddrString(&(addr->addr), fqdn, sizeof(fqdn)),
+-			error));
++    else
++      DEBUG_printf(("8http_resolve_cb: \"%s\" did not resolve: %d",
++		    httpAddrString(&(addr->addr), fqdn, sizeof(fqdn)),
++		    error));
+ #endif /* DEBUG */
+-      }
++  } else {
++   /*
++    * Use the IP address that responded...
++    */
+ 
+-      httpAddrFreeList(addrlist);
+-    }
++   avahi_address_snprint (fqdn, sizeof (fqdn), address);
++   hostTarget = fqdn;
+   }
+ 
+  /*
diff --git a/cups.spec b/cups.spec
index 2f24a37..1b27fc9 100644
--- a/cups.spec
+++ b/cups.spec
@@ -11,7 +11,7 @@ Summary: CUPS printing system
 Name: cups
 Epoch: 1
 Version: 1.6.2
-Release: 3%{?dist}
+Release: 4%{?dist}
 License: GPLv2
 Group: System Environment/Daemons
 Url: http://www.cups.org/
@@ -54,6 +54,7 @@ Patch23: cups-dnssd-deviceid.patch
 Patch24: cups-ricoh-deviceid-oid.patch
 Patch25: cups-systemd-socket.patch
 Patch26: cups-lpd-manpage.patch
+Patch27: cups-avahi-address.patch
 
 Patch100: cups-lspp.patch
 
@@ -221,6 +222,8 @@ Sends IPP requests to the specified URI and tests and/or displays the results.
 %patch25 -p1 -b .systemd-socket
 # Talk about systemd in cups-lpd manpage (part of bug #884641).
 %patch26 -p1 -b .lpd-manpage
+# Use IP address when resolving DNSSD URIs (bug #948288).
+%patch27 -p1 -b .avahi-address
 
 %if %lspp
 # LSPP support.
@@ -618,6 +621,9 @@ rm -f %{cups_serverbin}/backend/smb
 %{_mandir}/man5/ipptoolfile.5.gz
 
 %changelog
+* Thu Apr  4 2013 Tim Waugh <twaugh at redhat.com> 1:1.6.1-4
+- Use IP address when resolving DNSSD URIs (bug #948288).
+
 * Thu Mar 28 2013 Tim Waugh <twaugh at redhat.com> 1:1.6.1-3
 - Check for cupsd.conf existence prior to grepping it (bug #928816).
 


More information about the scm-commits mailing list