michaelrsweet / hp-printer-app

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

Ability to modify server options with snap #21

Closed cptaffe closed 1 year ago

cptaffe commented 1 year ago

Is your feature request related to a problem? Please describe.

The article A New Way to Print in Linux mentions Snaps several times, so I assume it's the preferred installation method.

When installing hp-printer-app via snap, the service runs this file which contains hardcoded options. This results in being unable to solve simple issues such as:

[Client 1] Accepted connection from '10.0.2.163'.
[Client 1] HTTP_STATE_GET http://printserver.home.arpa:8000/ HTTP/1.1 (en-US,en;q=0.9)
[Client 1] Bad Host: header 'printserver.home.arpa'.
[Client 1] Bad Request
[Client 1] Closing connection from '10.0.2.163'.

Describe the solution you'd like

I believe at least the first issue is fixable via configuration options, passed via -o (as documented here), but since snaps are immutable I'm unable to edit the hp-printer-app-server file. I believe snap configuration could provide a way to expose each -o as a config option, settable via snap set hp-printer-app-server ....

michaelrsweet commented 1 year ago

The listen hostname stuff will be resolved with the next release - required some changes in PAPPL which have now been released.

I'll look at supporting snap configuration here and in LPrint.

michaelrsweet commented 1 year ago

Oh, I should note that PAPPL-based printer applications will try to defend against DNS rebinding attacks, so all client requests need to target the mDNS hostname ("hostname.local"), the system hostname (whatever "hostname" reports), an IP address, or (for loopback/domain socket access) "localhost". Right now there is no provision for a system that has multiple FQDNs beyond "hostname.local" and "hostname.domain"...

michaelrsweet commented 1 year ago

OK, so I have this implemented for LPrint and will carry that over to hp-printer-app as well...

cptaffe commented 1 year ago

I set the system hostname to be the domain I use on my local network, e.g. printserver.home.arpa, but I would like to be able to use a non-hostname domain and proxy to different printer app UIs + CUPS via nginx. The connection from nginx would be via localhost, but the Host header would report the original domain, e.g. printer-apps.home.arpa -- would that fail for PAPPL-based applications?

michaelrsweet commented 1 year ago

Right now PAPPL isn't setup to support multiple domain names. It is intended only to support local direct printing with future support for the IPP "Shared Infrastructure" (cloud) extensions to allow remote network access vs. trying to use brittle (and insecure) HTTP/SSH proxy solutions and exposing a local server to a WAN/the Internet.

michaelrsweet commented 1 year ago

[master 7f8980f] Update snap to support configuration and PAPPL 1.3.1 (Issue #21)

cptaffe commented 1 year ago

@michaelrsweet when will these changes be available? The version available to me (1.2.0) doesn't have the ability to snap set hp-printer-app server-hostname=hp-printer-app.home.arpa.

; snap info hp-printer-app
name:      hp-printer-app
summary:   HP Printer Application
publisher: Michael Sweet (michaelrsweet)
store-url: https://snapcraft.io/hp-printer-app
license:   unset
description: |
  HP Printer Application is sample printer application for Hewlett Packard PCL
  (and compatible) printers.  It is based on PAPPL (Printer Application
  Framework), a simple C-based framework/library for developing CUPS Printer
  Applications, which are the recommended replacement for printer drivers.
commands:
  - hp-printer-app
services:
  hp-printer-app.hp-printer-app-server: simple, enabled, active
snap-id:      TsR8cclxOUKWUcf96gkX5B0XjlB2kr5J
tracking:     latest/stable
refresh-date: today at 13:54 EDT
channels:
  latest/stable:    1.2.0 2022-11-03 (386) 2MB -
  latest/candidate: 1.2.0 2022-11-03 (386) 2MB -
  latest/beta:      1.2.0 2022-11-03 (386) 2MB -
  latest/edge:      1.2.0 2022-11-03 (386) 2MB -
installed:          1.2.0            (386) 2MB -