michaelrsweet / hp-printer-app

Example printer application for HP PCL printers using PAPPL.
Apache License 2.0
32 stars 6 forks source link

hp-printer-app runs as server but web interface not accessible #7

Closed tillkamppeter closed 3 years ago

tillkamppeter commented 3 years ago

To investigate michaelrsweet/pappl#135 I tried to start hp-printer-app again, it is starting up and keeps running this time but I cannot access its web interface.

I have tried both building and starting it directly and building and starting it as a Snap. I am using current GIT state of both hp-printer-app and PAPPL, and the OpenPrinting version of CUPS.

Command line to run it is

hp-printer-app -o log-level=debug -o server-port=8000 server

The web interface gets advertised via DNS-SD and gets listed in the output of avahi-discover. If I do not specify -o server-port=8000 it gets listed as on port 0, therefore I specified the port (which I do not need for testpappl or for the PostScript Printer Application).

I cannot access https://localhost:8000/ nor https://till-x1yoga.local:8000/ with a web browswer.

The log shows:

I [2021-01-26T17:21:29.575Z] Starting log, system up 0 second(s), 0 printer(s), listening for connections on 'till-x1yoga.local:8000'.
D [2021-01-26T17:21:29.575Z] Adding 'image/jpeg' to 'image/pwg-raster' filter.
D [2021-01-26T17:21:29.575Z] Adding 'image/png' to 'image/pwg-raster' filter.
I [2021-01-26T17:21:29.575Z] Listening for connections on '/tmp/hp-printer-app1000.sock'.
D [2021-01-26T17:21:29.575Z] Adding resource for '/favicon.png'.
D [2021-01-26T17:21:29.575Z] Adding resource for '/navicon.png'.
D [2021-01-26T17:21:29.575Z] Adding resource for '/style.css'.
D [2021-01-26T17:21:29.575Z] Adding resource for '/'.
D [2021-01-26T17:21:29.575Z] Adding resource for '/addprinter'.
D [2021-01-26T17:21:29.575Z] Adding resource for '/config'.
I [2021-01-26T17:21:29.575Z] Starting system.
D [2021-01-26T17:21:29.575Z] Registering DNS-SD name 'hp-printer-app' on 'till-x1yoga.local'
D [2021-01-26T17:21:30.577Z] Registering DNS-SD name 'hp-printer-app' on 'till-x1yoga.local'

If I try to access with a browser nothing gets added to the log.

I can access the server with hp-printer-app by itself:

$ hp-printer-app status
Running, idle since Wed, 31 Dec 1969 23:00:00 GMT
$

and this actually adds to the log:

I [2021-01-26T17:33:52.819Z] [Client 1] Accepted connection from 'localhost'.
I [2021-01-26T17:33:52.820Z] [Client 1] POST http://localhost:0/ipp/system HTTP/1.1
I [2021-01-26T17:33:52.820Z] [Client 1] Continue
D [2021-01-26T17:33:52.820Z] [Client 1] 0x005b request: IPP/2.0 request-id=1
D [2021-01-26T17:33:52.820Z] [Client 1] 0x005b request: operation-attributes-tag
D [2021-01-26T17:33:52.820Z] [Client 1] 0x005b request:   attributes-charset charset utf-8
D [2021-01-26T17:33:52.820Z] [Client 1] 0x005b request:   attributes-natural-language naturalLanguage en-us
D [2021-01-26T17:33:52.820Z] [Client 1] 0x005b request:   system-uri uri ipp://localhost/ipp/system
D [2021-01-26T17:33:52.820Z] [Client 1] 0x005b request:   requesting-user-name nameWithoutLanguage till
D [2021-01-26T17:33:52.820Z] [Client 1] 0x005b request:   requested-attributes 1setOf keyword system-state,system-state-change-date-time,system-state-reasons
D [2021-01-26T17:33:52.820Z] papplSystemFindPrinter(system=0x5652b6e214d0, resource="(null)", printer_id=0, device_uri="(null)")
D [2021-01-26T17:33:52.820Z] papplSystemFindPrinter: Returning (nil)(none)
D [2021-01-26T17:33:52.820Z] [Client 1] IPP/2.0 0x005b (CUPS/2.2.7 (Linux 5.4.0-44-generic; x86_64) IPP/2.0)
I [2021-01-26T17:33:52.820Z] [Client 1] 0x005b successful-ok
I [2021-01-26T17:33:52.820Z] [Client 1] OK application/ipp 171
D [2021-01-26T17:33:52.820Z] [Client 1] 0x005b response: IPP/2.0 request-id=1, status-code=successful-ok
D [2021-01-26T17:33:52.820Z] [Client 1] 0x005b response: operation-attributes-tag
D [2021-01-26T17:33:52.820Z] [Client 1] 0x005b response:   attributes-charset charset utf-8
D [2021-01-26T17:33:52.820Z] [Client 1] 0x005b response:   attributes-natural-language naturalLanguage en-us
D [2021-01-26T17:33:52.820Z] [Client 1] 0x005b response: 0x0a
D [2021-01-26T17:33:52.820Z] [Client 1] 3 response:   system-state enum 3
D [2021-01-26T17:33:52.820Z] [Client 1] 3 response:   system-state-change-date-time dateTime 1970-01-01T00:00:00Z
D [2021-01-26T17:33:52.820Z] [Client 1] 3 response:   system-state-reasons keyword none
I [2021-01-26T17:33:52.821Z] [Client 1] Closing connection from 'localhost'.

For me it seems that hp-printer-app is only listening on its socket, /tmp/snap.hp-printer-app/tmp/hp-printer-app1000.sock. This makes the web interface unusable. How can I tell it on the server command line to listen on the URL so that I can access with a web browser?

Or is there a bug in the Printer Application?

tillkamppeter commented 3 years ago

By looking into the source code of PAPPL I have found out how to make the web interface available, it requires -o server-name=...:

hp-printer-app -o log-level=debug -o server-name=localhost -o server-port=8000 server

This should either get mentioned in the README.md or better, either localhost or the server's FQDN should be default and for using it only via the socket a -o socket-only option should be added. Printer Applications should be easy-to-use printer drivers.

michaelrsweet commented 3 years ago

@tillkamppeter There are serious security considerations when making a web interface available on a TCP/IP interface.

As for the port number, it should be assigning one automatically in the 8xxx range.

Both of those are PAPPL issues, since hp-printer-app is just an example application for PAPPL.

Tracking this in the PAPPL project as PAPPL Issue #147.