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

cannot get cups to send IP address in printer URIs #3737

Closed
michaelrsweet opened this Issue Dec 1, 2010 · 5 comments

Comments

Projects
None yet
1 participant
@michaelrsweet
Copy link
Collaborator

michaelrsweet commented Dec 1, 2010

Version: 1.4.4
CUPS.org User: wrosenauer

In my local network environment I cannot reach the cups server via its configured FQDN (hostname+domainname) but only by a different name or IP directly.
I cannot get cups to use its ip address for the local printer URIs in its broadcast messages although "ServerName IPADDRESS" should apparently do the trick.

The relevant parts of my cupsd.conf:
ServerName 192.168.250.1
HostNameLookups off
Browsing On
BrowseOrder allow,deny
BrowseAllow all
BrowseLocalProtocols CUPS
BrowseAddress @if(eth0)
BrowseAddress @Local

After CUPS server restart I still get the following data in its broadcast packets:
URI: ipp://Hygiea.rosenauer.org:631/printers/officejet

This is cups 1.4.4 on openSUSE 11.3 (64bit)

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

michaelrsweet commented Dec 2, 2010

CUPS.org User: jp107

I was an idiot earlier and tried replying to the mail message that the STR generated. Sorry for any noise that caused.

Anywat this is my message:

At least in earlier versions of cups, the cups/ipp adverts contain the name/address that cups determines is correct for the interface that the advert is being sent from and isn't related to ServerName at all.

ie for cups-1.3.7 (I happen to have that source at hand) in scheduler/dirsvc.c is the function send_cups_browse() which contains:

...
for (i = NumBrowsers, b = Browsers; i > 0; i --, b ++)
if (b->iface[0])
{
/*
* Send the browse packet to one or more interfaces...
*/
...
for (iface = (cupsd_netif_t *)cupsArrayFirst(NetIFList);
iface;
iface = (cupsd_netif_t *)cupsArrayNext(NetIFList))
{
...
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
iface->hostname, iface->port,
(p->type & CUPS_PRINTER_CLASS) ? "/classes/%s" :
"/printers/%s",
p->name);
...

so the name/address used is unrelated to what ServerName is set to - it will be looking up the name of the address that it thinks is associated with the interface...

Depending on your setup you may be able to get what you want by one or more of:

getting cups to only listen on the address that the adverts
should include a reference to

changing browseaddress to not include interfaces which arn't the ones
you want

use browserelay to send to a specific address/network

In one of our bits of network we have a cups server on a gateway between a network with the 'real cups servers' and the client machines. There is a firewall so the clients wouldn't see adverts from the real servers, so we added a cups server on the gateway which uses browsepoll to the real servers to obtain a list and browserelay to forward the cups adverts that cups-polld sends to cupsd on to the client networks... It is ugly but it does work...

If this helps you then great, if not I may not have explained myself very clearly; or I may have misunderstood what you are trying to do.

None of this should be assumed to be true without checking with either an expert or the current cups source (or both).

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

michaelrsweet commented Dec 2, 2010

CUPS.org User: wrosenauer

The hostname which is sent is basically fine and exactly the one which one would get asking for the name for the local address of the interface where it's supposed to listen. It's just that no other machine in the network knows that name.
So if ServerName is not doing the thing I would have expected that
HostNameLookups off
would do it.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

michaelrsweet commented Dec 2, 2010

CUPS.org User: jp107

Hmm, I always thought that HostNameLookups only affected lookups from client IP addresses (which is what the manual seems to imply), but in cups-1.3.7 I see in network.c cupsdNetIFUpdate() a test which seems to imply what you expected would work:

...
for (addr = addrs; addr != NULL; addr = addr->ifa_next)
{
...
if (HostNameLookups)
httpAddrLookup((http_addr_t )(addr->ifa_addr), hostname,
sizeof(hostname));
else
{
/

* Map the default server address and localhost to the server name
* and localhost, respectively; for all other addresses, use the
* dotted notation...
*/

  if (httpAddrLocalhost((http_addr_t *)(addr->ifa_addr)))
    strcpy(hostname, "localhost");
  else
  {
    for (saddr = ServerAddrs; saddr; saddr = saddr->next)
  if (httpAddrEqual((http_addr_t *)(addr->ifa_addr), &(saddr->addr)))
    break;

if (saddr)
      strlcpy(hostname, ServerName, sizeof(hostname));
else
      httpAddrString((http_addr_t *)(addr->ifa_addr), hostname,
             sizeof(hostname));
  }
}

...

but in cups-1.4.5 that test for HostNameLookups has changed to:

...
/*
* Try looking up the hostname for the address as needed...
*/

#ifdef APPLE
if (HostNameLookups)
#else
if (HostNameLookups || RemotePort)
#endif /* APPLE */
httpAddrLookup((http_addr_t *)(addr->ifa_addr), hostname,
sizeof(hostname));
...

where RemotePort starts off as zero but gets set to the last port specified in a (non-local) listen (or port) directive (see conf.c).

You could change the source to do what you want (and probably used to work) but currently there doesn't seem to be a way to configure the old behaviour.

I note that several tests for HostNameLookups have now changed into (HostNameLookups || RemotePort) so this probably affects other things too.

Sorry I missed that ...->hostname might not be the DNS name earlier.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

michaelrsweet commented Jan 7, 2011

CUPS.org User: mike

Fixed in Subversion repository.

(This was actually already addressed in trunk for CUPS 1.5.x, but the change was not applied to CUPS 1.4.x...)

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

michaelrsweet commented Jan 7, 2011

"str3737.patch":

Index: scheduler/network.c

--- scheduler/network.c (revision 9128)
+++ scheduler/network.c (revision 9129)
@@ -154,11 +154,7 @@
* Try looking up the hostname for the address as needed...
*/

-#ifdef APPLE
if (HostNameLookups)
-#else

  • if (HostNameLookups || RemotePort)
    -#endif /* APPLE /
    httpAddrLookup((http_addr_t *)(addr->ifa_addr), hostname,
    sizeof(hostname));
    else
    @@ -166,7 +162,7 @@
    /

  • Map the default server address and localhost to the server name

  • and localhost, respectively; for all other addresses, use the

  •  \* dotted notation...
    
  •  * numeric address...
    

    */

    if (httpAddrLocalhost((http_addr_t *)(addr->ifa_addr)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.