lprint icon indicating copy to clipboard operation
lprint copied to clipboard

Snap not registering printers with local Avahi-Daemon

Open donicrosby opened this issue 8 months ago • 6 comments

I'm running into this issue where no matter how I configure LPrint either directly on my machine or via Snap my label printer will not show up on the network.

I'm running this on a Raspberry Pi with the Rollo plugged in via USB. I'm not sure if there's some configuration I'm missing on the local avahi-daemon that would allow the Snap to do what it needs to.

donicrosby avatar Apr 25 '25 16:04 donicrosby

Hmm, what distro are you running on your Raspberry Pi?

Are you seeing any errors in the LPrint log file (should be accessible via the web interface...)?

michaelrsweet avatar Apr 25 '25 16:04 michaelrsweet

I'm running Raspbian Bookworm,

This is a print server with no monitor attached. I have never got the web interface to work at all. I have tried setting the hostname for the server as the hostname for the Pi. But every time I go to port 8000 I get a 400 Bad Request and saying the Host header is bad.

donicrosby avatar Apr 25 '25 16:04 donicrosby

I was about to report the issue with "400 Bad Request". It turns out lprint doesn't like to be accessed by name. It runs on Raspberry Pi Zero 2 W with Debian 12 in my case, on a host named pzero. If I go to http://pzero:8000/ in a browser, I get 400 - Bad Request in response, and journalctl -f on the system running lprint shows

May 25 19:19:40 pzero lprint.lprint-server[2325]: E [2025-05-26T02:19:40.409Z] [Client 16] Bad Host: header 'pzero'.

I checked the lprint and pappl sources for "Bad Host", it's actually in pappl. The log statement is preceded by a long condition, which evaluates to false if the hostname starts with a digit or with [. That gave me an idea to use numeric IPv4 address instead of pzero, and it worked perfectly. IPv6 addresses in square brackets work too.

I wonder what's the reason for rejecting unknown hostnames by default. I don't see it as a security measure. The default should be easy to use. If some users want virtual hosting, they should configure it. I would also expect the configuration to be described better.

proski avatar May 26 '25 02:05 proski

@proski PAPPL checks that the name in the Host: header matches the local hostname in order to protect the printer application from DNS rebinding attacks that are common against HTTP-based services. "pzero.local" should work, but PAPPL currently doesn't track hostnames without a domain such as "pzero". I can certainly look at adding support for something like CUPS's ServerAlias directive so that you can allow specific hostnames in addition to the auto-detected FQDNs.

michaelrsweet avatar May 26 '25 21:05 michaelrsweet

@proski Tracking host alias support here.

michaelrsweet avatar May 26 '25 21:05 michaelrsweet

@michaelrsweet Yes, pzero.local is working, thank you!

proski avatar May 29 '25 18:05 proski

OK, I'll close the LPrint issue and will work on the PAPPL issue separately.

michaelrsweet avatar Oct 01 '25 00:10 michaelrsweet