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

cupsGetDests2 only shows Discovered printer when using http=CUPS_HTTP_DEFAULT #5925

Open
cregganna opened this issue Jun 3, 2021 · 4 comments

Comments

@cregganna
Copy link

Not sure if this is actually an issue - I'm looking more for advice on whether this is a setup issue or just that one should be using cupsEnumDests rather than cupsGetDests2.

I have a Linux application that uses cupsGetDests2 with http=CUPS_HTTP_DEFAULT to enumerate the printers to present to the user. It mostly fails to show the only printer on the network - all other applications on the box correctly show the printer is available.

The setup is:

  • System: Ubuntu 20.04.2 LTS (Actually Xubuntu)
  • Cups version is 2.3.1: See attached cups-versions.txt
  • cups and cups-browsed are running as services
  • No local printers defined
  • One printer on the network - Brother_MFC_9330CDW that is advertising itself with a number of protocols including ipp, lpd, AirPrint, Web Services, mDNS etc
  • lpinfo shows the printer being discovered and configured: See attached lpinfo-v.txt
  • I have written two C programs attached with Makefile and sample outputs:
    Cups-Client-Examples.zip
    You will note that the cupsGetDests2 call never sees the fully configured version of the printer.
    The cupsEnumDests always sees two entries for the printer, one fully configured and the other CUPS_PRINTER_DISCOVERED one.
  • I've stepped through the code both programs are connecting to the socket: /var/run/cups/cups.sock

The application concerned tries to filter out the CUPS_PRINTER_DISCOVERED printer after calling the cupsGetDests2 and this results in no printers being available.

Sorry about the long ramble but finally to my questions:

  • Should this application be using cupsGetDests2 or should it be using cupsEnumDests?
    The application can be configured to use a print server url and if done so it passes this in as the http parameter instead of the CUPS_HTTP_DEFAULT - I see that cupsEnumDests does not take an http paramater.
  • As can be seen from the attached outputs both Destinations have the same name and an Instance of NULL. This means that while the cups code is iterating through the printers in its call back method (cups_get_cb) building the dests pointer array and removing duplicates it overwrites the fully configured printer definition with the CUPS_PRINTER_DISCOVERED one - so losing the configured one.
    As such - should the cupsGetDests2 call also mask out Discovered printers for local printer enumerations?
    See here:

    cups/cups/dest.c

    Line 1691 in 64160c2

    if (!httpAddrLocalhost(httpGetAddress(http)))
  • Or maybe, this is a configuration issue. Should the destinations for the printer have an instance to identify it as unique - One configured the other is not?
  • Should the printer advertise its name differently on the various protocols?

Your inputs on this would be very appreciated.

@cregganna
Copy link
Author

Hi again, Just gently giving this a bump.

Can we have some direction on this please - maybe answering the question:

  • Should this application be using cupsGetDests2 or should it be using cupsEnumDests?

Many Thanks

@michaelrsweet
Copy link
Collaborator

@cregganna You should probably report this to the OpenPrinting CUPS repository, as Apple is no longer providing assistance for Linux users of CUPS and my access to this repository is extremely limited at the moment...

That said, cupsGetDests2 and cupsEnumDests should return substantially the same list of destinations since cupsGetDests2 is implemented using cupsEnumDests in CUPS 2.3.x - the only differences might be for printers that don't response immediately to a discovery query. Generally speaking, interactive applications should use cupsEnumDests while non-interactive applications should use cupsGetDests2.

As for why you aren't seeing the printer, cups-browsed will normally create a queue for every printer it sees (which is actually not what I'd like to see, since CUPS can dynamically create a queue as needed), but the "discovered" queue can be used with the CUPS API and CUPS will automatically create a queue for it.

@michaelrsweet
Copy link
Collaborator

@cregganna Oh, and just re-reading your original message, cupsGetDests2 only enumerates printers when the HTTP connection is local (either CUPS_HTTP_DEFAULT or an explicit connection to the domain socket or localhost IP sockets...)

@cregganna
Copy link
Author

Michael, thanks for your reply - I did not fully understand that the cups running on my own Linux box was not from this repo - I will post the same question in OpenPrinting CUPS.

Note though, that Apple users are also reporting this issue.

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

No branches or pull requests

2 participants