Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipp backend incorrectly inherits IPP_PORT environment variable #852

Closed
michaelrsweet opened this issue Aug 14, 2004 · 5 comments
Closed
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.1.21rc1
CUPS.org User: walters.redhat

The ipp backend will use the value of the IPP_PORT environment variable, which is wrong - if the scheudler is listening on a nonstandard port then the ipp backend will attempt to contact remote printers on that port too.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Hmm, I'm auditing this patch right now, and I'm not sure that it is a complete fix.

In looking at the directory services code (aka browsing), it looks like we are not sending the port number as part of the advertisement, which means that a non-standard port assignment will cause this patch to disable remote printing (since it won't get the port number change...)

It looks like we need to update httpSeparate() to use port 631 when it sees the "ipp" scheme and pass the port number in the URI for any advertisements to get this to work properly.

Will post a new patch once we have this implemented...

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Please try the attached patch and let me know if it resolves things for you...

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in CVS - the anonymous CVS repository will be updated at midnight EST.

@michaelrsweet
Copy link
Collaborator Author

"cups-no-propagate-ipp-port.patch":

--- cups-1.1.21rc1/backend/ipp.c~ 2004-08-12 18:54:45.000000000 -0400
+++ cups-1.1.21rc1/backend/ipp.c 2004-08-13 11:56:52.766254976 -0400
@@ -273,6 +273,17 @@
if (content_type == NULL)
content_type = "application/octet-stream";

  • /*
  • * The scheduler sets IPP_PORT in the environment to
  • * point back to whatever port it's running on.
  • * That's not interesting to us because we want
  • * to talk to remote IPP servers, which by default
  • * will be listening to the standard IPP port 631.
  • * If they aren't, the URI will should a port
  • * value, which will override this.
  • */
  • ippSetPort(IPP_PORT);

/*

  • Extract the hostname and printer name from the URI...
    */

@michaelrsweet
Copy link
Collaborator Author

"str852.patch":

Index: cups/http-support.c

RCS file: /development/cvs/cups/cups/http-support.c,v
retrieving revision 1.13
diff -u -r1.13 http-support.c
--- cups/http-support.c 2 Jul 2004 04:05:34 -0000 1.13
+++ cups/http-support.c 18 Aug 2004 16:00:44 -0000
@@ -211,7 +211,7 @@
else if (strcasecmp(method, "https") == 0)
*port = 443;
else if (strcasecmp(method, "ipp") == 0)

  •  *port = ippPort();
    
  •  *port = 631;
    

    else if (strcasecmp(method, "lpd") == 0)
    port = 515;
    else if (strcasecmp(method, "socket") == 0) /
    Not registered yet... */

    Index: scheduler/dirsvc.c

    RCS file: /development/cvs/cups/scheduler/dirsvc.c,v
    retrieving revision 1.134
    diff -u -r1.134 dirsvc.c
    --- scheduler/dirsvc.c 17 Jul 2004 02:29:59 -0000 1.134
    +++ scheduler/dirsvc.c 18 Aug 2004 16:00:44 -0000
    @@ -672,11 +672,11 @@

    • Only send to local interfaces...
      */
  • if (!iface->is_local)
    
  • if (!iface->is_local || !iface->port)
    continue;
    
  • snprintf(packet, sizeof(packet), "%x %x ipp://%s/%s/%s \"%s\" \"%s\" \"%s\"\n",
    
  •          type, p->state, iface->hostname,
    
  • snprintf(packet, sizeof(packet), "%x %x ipp://%s:%d/%s/%s \"%s\" \"%s\" \"%s\"\n",
    
  •          type, p->state, iface->hostname, iface->port,
       (p->type & CUPS_PRINTER_CLASS) ? "classes" : "printers",
       p->name, p->location ? p->location : "",
       p->info ? p->info : "",
    

    @@ -700,8 +700,11 @@
    * Send to the named interface...
    */

  • snprintf(packet, sizeof(packet), "%x %x ipp://%s/%s/%s "%s" "%s" "%s"\n",

  •        type, p->state, iface->hostname,
    
  • if (!iface->port)

  • continue;
    
  • snprintf(packet, sizeof(packet), "%x %x ipp://%s:%d/%s/%s "%s" "%s" "%s"\n",

  •        type, p->state, iface->hostname, iface->port,
     (p->type & CUPS_PRINTER_CLASS) ? "classes" : "printers",
     p->name, p->location ? p->location : "",
     p->info ? p->info : "",
    

    Index: scheduler/network.c

    RCS file: /development/cvs/cups/scheduler/network.c,v
    retrieving revision 1.13
    diff -u -r1.13 network.c
    --- scheduler/network.c 29 Jun 2004 03:27:35 -0000 1.13
    +++ scheduler/network.c 18 Aug 2004 16:00:44 -0000
    @@ -129,6 +129,8 @@
    void
    NetIFUpdate(void)
    {

  • int i; /* Looping var */

  • listener_t lis; / Listen address /
    cups_netif_t *temp; /
    Current interface /
    struct ifaddrs *addrs, /
    Interface address list /
    *addr; /
    Current interface address */
    @@ -192,6 +194,19 @@
    if (!(addr->ifa_flags & IFF_POINTOPOINT) &&
    ntohl(temp->address.sin_addr.s_addr) != 0x7f000001)
    temp->is_local = 1;

  • /*
  • * Determine which port to use when advertising printers...
  • */
  • for (i = NumListeners, lis = Listeners; i > 0; i --, lis ++)

  •  if (lis->address.sin_addr.s_addr == 0x00000000 ||
    
  •      (lis->address.sin_addr.s_addr & temp->mask.sin_addr.s_addr) ==
    
  •     temp->address.sin_addr.s_addr)
    
  •  {
    
  •    temp->port = ntohs(lis->address.sin_port);
    
  • break;

  •  }
    

    /*

    • Finally, try looking up the hostname for the address as needed...
      Index: scheduler/network.h

      RCS file: /development/cvs/cups/scheduler/network.h,v
      retrieving revision 1.3
      diff -u -r1.3 network.h
      --- scheduler/network.h 25 Feb 2004 20:14:53 -0000 1.3
      +++ scheduler/network.h 18 Aug 2004 16:00:44 -0000
      @@ -33,7 +33,8 @@
      char name[32], /* Network interface name /
      hostname[HTTP_MAX_HOST];
      /
      Hostname associated with interface */
  • int is_local; /* Local (not point-to-point) interface? */

  • int is_local, /* Local (not point-to-point) interface? */

  •       port;       /\* Listen port _/
    

    struct sockaddr_in address, /_ Network address /
    mask, /
    Network mask /
    broadcast; /
    Broadcast address */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant