OpenPrinting / cups

OpenPrinting CUPS Sources
https://openprinting.github.io/cups
Apache License 2.0
1.01k stars 182 forks source link

Temp queues don't work on LFS/BLFS OS due missing mDNS resolver/resolver plugin #771

Closed FosterSM closed 1 year ago

FosterSM commented 1 year ago

Version cups 2.4.6. LFS/BLFS Version 11.3 Linux Kernel 5.15.120

I have a firewall system (moira) that hosts a cups server. The cups server is configured with 3 printers. 1 HP5550 on a Windows 10 machine on my internal network. 2 HP7760 a USB printer on the firewall machine (moira). 3 HP6020e a wifi printer accessed via my internal network. There are two problems:

The three printers print fine from applications run on the firewall (moira).
On client machines the printers are shown to exist but the names are wrong.
Also they report as "Getting Printer Information Failed" when attempting to print on them.

All the machines report a phantom printer which appears to be a direct connection to the wifi printer:
HP_ENVY_6000_Series_726F10
All machine report it as "Off line".

In addition to the Cups software the firewall machine has hplip-3.23.5 installed for printer and scanner access.

So my questions are how do I get the client systems to use the correct access to the print services on moira and how do I get rid of the phantom printer.

Thanks

zdohnal commented 1 year ago

Hi,

the bug report template has a link to https://github.com/OpenPrinting/cups/blob/master/REPORTING_ISSUES.md , which is very helpful when filing an issue, especially point 6.

From the data you have provided, the error your application gives you reminds me older versions of GTK, so it is really important to find out whether everything works via CUPS tools at first.

Regarding 'phantom printer' - it is a temporary queue which usually works via CUPS tools, so again it would be great whether you find if CUPS tools works and if they do, report to the application. But since you probably want to have all printing going via the server, I would recommend turning off dns-sd/bonjour on the printer and installing it permanently on the server, which will advertise it as IPP service on your local network.

Since you set CUPS on your server, I recommend reading https://openprinting.github.io/cups/doc/security.html .

FosterSM commented 1 year ago

zdohnal

Here is the information from my cupsd server moira which I think looks ok:

lpstat -l -e HP5550 permanent ipp://localhost/printers/HP5550 lpd://littleblue/hp5550 HP6020e permanent ipp://localhost/printers/HP6020e socket://hp6020e HP7760 permanent ipp://localhost/printers/HP7760 usb://hp/photosmart%207700%20series?serial=MY4C82K34BU0 HP_ENVY_6000_series_726F10 network none ipps://HP%20ENVY%206000%20series%20%5B726F10%5D._ipps._tcp.local/

lpstat -t scheduler is running no system default destination device for HP5550: lpd://littleblue/hp5550 device for HP6020e: socket://hp6020e device for HP7760: usb://hp/photosmart%207700%20series?serial=MY4C82K34BU0 HP5550 accepting requests since Wed 02 Aug 2023 21:24:18 BST HP6020e accepting requests since Wed 02 Aug 2023 21:33:19 BST HP7760 accepting requests since Wed 02 Aug 2023 21:28:41 BST printer HP5550 is idle. enabled since Wed 02 Aug 2023 21:24:18 BST printer HP6020e is idle. enabled since Wed 02 Aug 2023 21:33:19 BST printer HP7760 is idle. enabled since Wed 02 Aug 2023 21:28:41 BST

lpstat -v device for HP5550: lpd://littleblue/hp5550 device for HP6020e: socket://hp6020e device for HP7760: usb://hp/photosmart%207700%20series?serial=MY4C82K34BU0

However running the same commands on one of my client machines (same cups version and LFS/BLFS version, Kernel is 6.4.7)

I get the following:

lpstat -l -e Hp5550_Inkjet_Printer_Moira network none ipps://Hp5550%20Inkjet%20Printer%20%40%20Moira._ipps._tcp.local/cups HP6020e_Moira network none ipps://HP6020e%20%40%20Moira._ipps._tcp.local/cups HP_ENVY_6000_series_726F10 network none ipps://HP%20ENVY%206000%20series%20%5B726F10%5D._ipps._tcp.local/ hp_photosmart_7700_series_Moira network none ipps://hp%20photosmart%207700%20series%20%40%20Moira._ipps._tcp.local/cups

lpstat -t lpstat: No destinations added. lpstat: No destinations added. lpstat: No destinations added. lpstat: No destinations added. scheduler is running no system default destination

lpstat -v lpstat: No destinations added.

Which looks wrong, this is consistent on all my client machines.

zdohnal commented 1 year ago

It is correct, they are temporary queues shared by your server and your printer, they don't have to be installed to work.

Do you get printouts on your printers if you do following from your client?:

$ for i in Hp5550_Inkjet_Printer_Moira HP6020e_Moira hp_photosmart_7700_series_Moira
do
  lp -d $i /etc/fstab
done

If you do, the problem is connected to the application you use - probably it doesn't use CUPS Destination API.

Regarding HP_ENVY_6000_series_726F10 you can turn off Bonjour/mDNS/DNS-SD functionality on your printer in case you want to use the printer via server.

FosterSM commented 1 year ago

Your test reports:

lp: The printer or class does not exist. lp: The printer or class does not exist. lp: The printer or class does not exist.

I use firefox and gnome Evolution email client and they both fail to print now. firefox is fine on the print server moira. They did use to print via moira this problem started when I deleted an old wifi printer on moira and added the Envy 6020e.

zdohnal commented 1 year ago

Was it the same client which reported printers via lpstat -l -e?

FosterSM commented 1 year ago

Yes I am using my main developent system (andromeda) for these tests, if I find a fix here I will apply it to my other linux systems.

zdohnal commented 1 year ago

Ok, check whether you see the printers via lpstat -l -e before you print - I find it strange they are reported as existing, but cannot be printed to.

Either way do enable CUPS debugging via cupsctl LogLevel=debug2 and do lpstat -l -e and lp -d Hp5550_Inkjet_Printer_Moira /etc/fstab and please upload logs as a file to this issue - Github allows uploading files with .txt suffix, so you can rename the log file. I'm not sure what is your log location on your OS - check /etc/cups/cups-files.conf for that.

FosterSM commented 1 year ago

lp -d hp_photosmart_7700_series_Moira /etc/fstab lp: The printer or class does not exist.

I chose this printer because it is in the same room as me and the HP5550 is in another room a distance away.

Sorry I cannot see how to upload the two log files.

FosterSM commented 1 year ago

I will send them in an e-mail.

FosterSM commented 1 year ago

Cups log files.

EDIT by zdohnal:

"Use the For... Google, Luke." - https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/attaching-files

log_771.txt

FosterSM commented 1 year ago

One other question that is bothering me on moira I see the printers by their queue name HP5550, HP6020e and HP7760. On my clients I used to see the same names, I now see the long names hp_photosmart_7700_series_Moira etc. why is this ?

FosterSM commented 1 year ago

Just for interests sake I have started up a copy of Ubuntu in virtualbox. It reports the printers correctly and I can print test pages using them. I have not used this virtual machine for some time but it has quite happly detected the new HP6020e Envy printer. (it is using v2.2.2 cups) . I have made a copy of its /etc/cups directory.

FosterSM commented 1 year ago

Here is a section of Wireshark capture of Moira starting the cups daemon:

moira-wireshark-771.txt

Here is a section of the information from Andromeda when lpstat -l -e is issued:

andromenda-lpstat-771.txt

The ouput from lpstat -l -e on Andromeda does not look right to me: root@Andromeda:~# lpstat -l -e Hp5550_Inkjet_Printer_Moira network none ipps://Hp5550%20Inkjet%20Printer%20%40%20Moira._ipps._tcp.local/cups

However on Moira : root@Moira:~# lpstat -l -e HP5550 permanent ipp://localhost/printers/HP5550 lpd://littleblue/hp5550

(editted to just include the one printer)

This implies to me that locally on Moira the correct information is being used but it is broadcasting the wrong information ???

Edited by zdohnal to use files.

zdohnal commented 1 year ago

One other question that is bothering me on moira I see the printers by their queue name HP5550, HP6020e and HP7760. On my clients I used to see the same names, I now see the long names hp_photosmart_7700_series_Moira etc. why is this ?

They are shared by DNS-SD, so they have server name at the end, which is okay.

This implies to me that locally on Moira the correct information is being used but it is broadcasting the wrong information ???

It shares information how to connect to the server, which shares the printer. This is the usual flow if you want to use a server - client -> server -> printer.

Ad the provided log - it does not show any error, probably GitHub cropped the comment because it was too long - please upload a file with the log for the frame when you tried to print. I would guess your machine uses /var/log/cups/error_log, so you can do following:

$ sudo cupsctl LogLevel=debug2
$ sudo tail -f /var/log/cups/error_log > log.txt &
$ lpstat -l -e
$ lp -d  hp_photosmart_7700_series_Moira /etc/fstab
$ sudo kill -15 `pidof tail`

and then upload log.txt to the issue.

FosterSM commented 1 year ago

Ok:

log.txt

zdohnal commented 1 year ago

Ad Ubuntu - Ubuntu runs cups-browsed by default, which takes DNS-SD services and makes them into permanent printers on localhost, with the same names as on the server. But temporary queues should work out of the box too.

FosterSM commented 1 year ago

Understood a later version of Ubuntu I tried has the same problem as I currently have on Andomeda/Moira.

zdohnal commented 1 year ago
E [07/Aug/2023:12:17:26 +0100] hp_photosmart_7700_series_Moira: Unable to connect to Moira.local:631: Name or service not known

can you ping Moira.local from the client?

$ ping Moira.local
FosterSM commented 1 year ago

Two points:

1, my domain is "delta" therefore Moira.local is invalid. 2, my firewall on moira is blocking pings to Moira. (all other destinations are ok and pings sent from Moira). I will check the settings and get back to you, pings from the internet should be blocked but not on the internal network.

zdohnal commented 1 year ago

To have it CUPS server work via mDNS, clients have to be able resolve its mDNS address and be able to connect to it to get information about the printer.

Pinging the mdns hostname is the easiest way to verify if the resolving works IMO - but avahi-resolve-host-name works for me as well, so in your case:

$ avahi-resolve-host-name Moira.local
FosterSM commented 1 year ago

avahi-resolve-host-name Moira.local works.

zdohnal commented 1 year ago

Is IPP opened in Moira's firewall for clients and cupsd set for allowing requests from the clients?

Can you ping Moira.local's port 631 via nc/netcat from client?

$ nc -vz Moira.local 631
FosterSM commented 1 year ago

I have changed my firewall settings: ping Moira.local Now works.

debiantriage commented 1 year ago

avahi-resolve-host-name Moira.local works.

avahi-resolve-host-name gets its information directly from the mDNS multicasts from hosts (it does not use the NSS functionality of libnss-mdns). This confirms Avahi is operating OK, which we already knew from getting an output from lpstat -l -e.

Lets have

nmap Moira.local
FosterSM commented 1 year ago

nmap Moira.local returns: Starting Nmap 7.93 ( https://nmap.org ) at 2023-08-07 15:11 BST Failed to resolve "Moira.local". WARNING: No targets were specified, so 0 hosts scanned. Nmap done: 0 IP addresses (0 hosts up) scanned in 0.07 seconds

nmap moira.delta returns: nmap.txt

zdohnal commented 1 year ago

nmap Moira.local returns: Starting Nmap 7.93 ( https://nmap.org ) at 2023-08-07 15:11 BST Failed to resolve "Moira.local".

Looks like your mDNS resolver is not stable (mDNS works with .local domains by standard, so Moira.local is mDNS hostname for your server in the local network - moira.delta is irrelevant in mDNS speaking). Unless the resolution is stable, temporary queues won't work.

You have mentioned pinging Moira.local worked. Does nmap Moira.local fail to resolve always and pinging Moira.local works at the same time?

debiantriage commented 1 year ago

If ping Moira.local works I fail to see why nmap Moira.local doesn't. Anyway, nmap.txt shows port 631 not to be filtered.

Don't forget @zdohnal's question about nc.

FosterSM commented 1 year ago

nc is not currently installed I will get it setup.

FosterSM commented 1 year ago

nc -vz Moira.local 631 Error: Couldn't resolve host "Moira.local"

FosterSM commented 1 year ago

I am going to check /etc/hosts with the LFS/BLFS config notes.

debiantriage commented 1 year ago

@zdohnal said

Ad Ubuntu - Ubuntu runs cups-browsed by default, which takes DNS-SD services and makes them into permanent printers on localhost, with the same names as on the server. But temporary queues should work out of the box too.

Not quite OOTB. cups-browsed has to be prevented from hijacking the destination: systemctl stop cups-browsed. Perhaps @FosterSM could try lp -d hp_photosmart_7700_series_Moira /etc/fstab after that.

FosterSM commented 1 year ago

/etc/hosts matches the LFS instructions for ipv4 and a defined hardware ip address. systemctl is a systemd program I use sysv, unless you meen on the old Ubuntu system ?l

FosterSM commented 1 year ago

On Ubuntu system: root@stuart-VirtualBox:: systemctl stop cups-browsed root@stuart-VirtualBox:: lp -d hp_photosmart_7700_series_Moira /etc/fstab lp: The printer or class does not exist. root@stuart-VirtualBox::

zdohnal commented 1 year ago

/etc/hosts matches the LFS instructions for ipv4 and a defined hardware ip address. systemctl is a systemd program I use sysv, unless you meen on the old Ubuntu system ?l

/etc/nsswitch.conf is the place where to look regarding mDNS, and its hosts line. There should have a mdns* string in it. Do you have nss-mdns installed? Once this plugin is installed, mdns/mdns4/mdns6/mdns_minimal/mdns4_minimal/mdns6_minimal should be added into /etc/nsswitch.conf.

FosterSM commented 1 year ago

My nssswitch.conf file: nsswitch.conf.txt

This is created in the LFS when building Glibc: https://lfs.koddos.net/lfs/view/stable/chapter08/glibc.html

There is no mention, I can find, in the LFS/BLFS about adding mDNS to nsswitch.conf the only reference to mDNS is on the AVAHI page: https://www.linuxfromscratch.org/blfs/view/svn/basicnet/avahi.html

zdohnal commented 1 year ago

I'm not LFS/BLFS author/maintainer, so I don't know what is in their documentation and how they provide mDNS resolution. But what I know is that you need a mDNS resolver and proper nsswitch.conf- nss-mDNS+Avahi or other - to make mDNS resolution working.

Is nss-mdns available on your distro?

FosterSM commented 1 year ago

Being fair to the LFS/BLFS folk the cups build info does refer off to the cups documentation: https://www.cups.org/documentation.html

FosterSM commented 1 year ago

No nss-mdns is not available in LFS/BLFS. I will message them and get their position.

zdohnal commented 1 year ago

Being fair to the LFS/BLFS folk the cups build info does refer off to the cups documentation: https://www.cups.org/documentation.html

cups.org is for Apple CUPS, our project is OpenPrinting CUPS, which was forked from Apple project.

FosterSM commented 1 year ago

I did wonder why the two projects. I have emailed the BLFS people I will get back to you when I have and answer.

zdohnal commented 1 year ago

If you don't have nss-mdns in your OS, you can fall back to:

  1. use cups-browsed with BrowsePoll <server hostname> on your clients or,
  2. use 'ServerName ' on your clients or,
  3. use 'CUPS_SERVER=' env variable on your clients or,
  4. install printers on your clients manually via lpadmin/CUPS Web UI, using uri to the Moira print server - f.e. lpadmin -p -v ipp://moira_hostname:631/printers/ -m everywhere -E

Each way has some downside and it is not exactly user friendly (you have to install the printer instead of letting mDNS+CUPS handle it for you), but it should work without mDNS resolution.

Downsides - 2 and 3 conflicts with 1 and clients are not able to change printer settings (if they don't have permissions on the server), 1 requires running daemon and 4 requires knowing the URI and has to be done for every printer.

zdohnal commented 1 year ago

Since the issue is due missing mDNS support on the specific OS, closing this issue from CUPS PoV.

Do let us know once the OS gets mDNS resolution support and accessing .local addresses works.

zdohnal commented 1 year ago

FTR, here is OpenPrinting CUPS documentation https://openprinting.github.io/cups/

FosterSM commented 1 year ago

Thanks

FosterSM commented 1 year ago

I have modified my nsswitch.conf:

Begin /etc/nsswitch.conf

passwd: files group: files shadow: files

hosts: files dns

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 networks: files

protocols: files services: files ethers: files rpc: files

End /etc/nsswitch.conf

and build and installed the nss-mdns package, I had to adjust the location of the Avahi sock from /usr/run/avahi-daemon/ socket to /run/avahi-daemon/socket. Now : getent hosts moira.local returns. 192.168.0.1 moira.local

I have also setup cups-browsed --debug Tue Aug 8 06:48:53 2023 Reading command line option --debug, turning on debug mode (Log on standard error). Tue Aug 8 06:48:53 2023 cups-browsed of cups-filters version 1.28.16 starting. Tue Aug 8 06:48:53 2023 Reading config: BrowseRemoteProtocols dnssd cups Tue Aug 8 06:48:53 2023 No "Browse..." line at all, accept all servers ("BrowseOrder Deny,Allow"). Tue Aug 8 06:48:53 2023 main() in THREAD 140249366951296 Tue Aug 8 06:48:53 2023 Remote support for DNSSD not supported Tue Aug 8 06:48:53 2023 cups-browsed: Creating http connection to local CUPS daemon via domain socket: /run/cups/cups.sock Tue Aug 8 06:48:53 2023 update_netifs() in THREAD 140249366951296 Tue Aug 8 06:48:53 2023 Network interfaces: lo (127.0.0.1, localhost.localdomain), eth0 (192.168.0.2, andromeda, 192.168.0.2*), lo (::1), eth0 (fe80::16da:e9ff:fe52:18b8) Tue Aug 8 06:48:53 2023 cups-browsed [BrowsePoll /run/cups/cups.sock:0]: IPP- Create-Subscription Tue Aug 8 06:48:53 2023 cups-browsed [BrowsePoll /run/cups/cups.sock:0]: subscription ID=11 Tue Aug 8 06:48:53 2023 cups-browsed (): cupsEnumDests Tue Aug 8 06:48:53 2023 Could not determine system default printer! Tue Aug 8 06:48:53 2023 Using signal handler SIGACTION Tue Aug 8 06:48:53 2023 listening

Now lpstat -l -e returns: Hp5550_Inkjet_Printer_Moira network none ipps://Hp5550%20Inkjet%20Printer%20%40%20Moira._ipps._tcp.local/cups HP6020e_Moira network none ipps://HP6020e%20%40%20Moira._ipps._tcp.local/cups HP_ENVY_6000_series_726F10 network none ipps://HP%20ENVY%206000%20series%20%5B726F10%5D._ipps._tcp.local/ hp_photosmart_7700_series_Moira network none ipps://hp%20photosmart%207700%20series%20%40%20Moira._ipps._tcp.local/cups

But the printers still are not operational remotley. There is probably more configuration needed.

zdohnal commented 1 year ago

Upload the .txt file with logs when you do 'lp -d hp_photosmart_7700_series_Moira /etc/fstab' to check what happened.

Ad cups-browsed:

Tue Aug 8 06:48:53 2023 Remote support for DNSSD not supported

your cups-browsed is not built with Avahi, so you have to use BrowsePoll, which I mentioned before.

FosterSM commented 1 year ago

Ok that is strange the print work and all the other printers are functional too. The cups-browsed has generated a long log: Cups3.txt Is this the correct behaviour ? For the record: lp -d hp_photosmart_7700_series_Moira /etc/fstab request id is hp_photosmart_7700_series_Moira-13 (1 file(s))

FosterSM commented 1 year ago

I am just checking if cups-browsed is built with AVAHI support it is a build option that may or may not have been set in my build.

FosterSM commented 1 year ago

It was not so I have rebuilt it with support for Avahi. New cups-browsed log: Cups4.txt This looks a lot better and printing is still working.

zdohnal commented 1 year ago

That's good to hear, but we are in CUPS project, so I meant CUPS logs, not cups-browsed logs. If mDNS is working, there is no need for cups-browsed.

Please turn off and disable cups-browsed, try to print via lp, collect CUPS log into .txt file and attach the file here.

If it works, temp queues are working after you get nss-mdns into your OS.