Call for testing: OpenPrinting's CUPS Snap

Hi,

I am Till Kamppeter, leader of the OpenPrinting project, home of CUPS, cups-filters and many other projects to make printing just work.

Now all needed changes on snapd got completed to get a fully working CUPS Snap into the Snap Store! See also the OpenPrinting News for the state of the art of its development.

The CUPS Snap is the complete printing stack for LInux and any other Snap-supporting operating system in a Snap. This integrates printing in operating systems which use Snaps or are even all-Snap, not using conventional (DEB, RPM, …) packages any more. It contains everything needed for printing on most modern printers in a single Snap: CUPS, cups-filters, cups-browed, Ghostscript, QPDF

The printing environment is protected by the security of Snaps, especially any inquiries from other confined Snaps go through a “cups” interface for standard user tasks like printing. listing jobs, removing one’s own jobs, … and “cups-control” for administrative tasks like creating and modifying print queues, removing anyone’s jobs, … With only “cups” being auto-connected without explicit permission when applications are put into the Snap Store one gets an additional level for getting applications which print from the Snap Store.

Classic CUPS printer drivers cannot be used any more as their components cannot be installed into the sandboxed CUPS system of the Snap. The CUPS Snap only accepts IPP printers, either driverless IPP printers, modern printers which do at least one of AirPrint, IPP Everywhere, Mopria, or Wi-Fi Direct Print (the printers on which you can print from a phone without needing a dedicated app), remote CUPS printers, or software emulations of IPP printers, the so-called Printer Applications, which are replacing the CUPS drivers (they send the jobs they receive off to a physical printer, converting the data to what the printer needs).

So in an all-Snap world a user application Snap (for example LibreOffice) sends print jobs to the CUPS Snap, CUPS spools and converts them to the needed format and then sends them off to the printers, or to the Printer Application Snap which serves as the driver for the printer.

In this post I want to ask you to test the new CUPS Snap

Before you install it, stop and disable the already installed CUPS, on modern Debian or Ubuntu distributions via the following commands:

sudo systemctl disable cups-browsed
sudo systemctl stop cups-browsed
sudo systemctl disable cups
sudo systemctl disable cups.socket
sudo systemctl stop cups

The “stop” commands stop the daemon immediately, the “disable” commands exclude it from being started during boot. Any configuration of them stays conserved and you can “enable” and “start” them again later (when you are done with testing the CUPS Snap).

Now install the Snap, either search for “CUPS” in the Snap Store/the Software application and then install the CUPS Snap, or enter the following in a terminal window:

sudo snap install --edge cups

The CUPS Snap (at least when there was no classic CUPS running when it was installed/started) uses the same socket and the same port as the standard (upstream or distro package) CUPS, so any locally running application and also the command line tools of your distro’s CUPS package use the snapped CUPS daemon now.

To the CUPS Snap’s CUPS daemon there is also a cups-browsed (included in the Snap) attached, so probably some print queues get already created automatically. lpstat -t tells you which queues are available. Administrative commands. like lpadmin or changing settings with cupsctl, can be run without sudo and without getting asked for a password by users in the “lpadmin” group or, if there is no such group in the system, by users in the “adm” group. Other users must use sudo to run the command as root.

The snap’s command line utilities (cups.lp, cups.lpadmin, …) can also be used but they can only access files in the calling user’s home directory if they are not hidden (name begins with a dot ‘.’). So you can usually print with a command like

cups.lp -d <printer> <file>

For hidden files you have to pipe the file into the command, like with

cat <file> | cups.lp -d <printer>

or copy or rename the file into a standard file.

The web interface can be accessed under

http://localhost:631/

To make administrative tasks working, you have to enter user name and password of a user in the “lpadmin” or “adm” group, or “root” and the root password if your system is configured appropriately.

Driverless IPP printers and remote CUPS printers should get available automatically, other printers will need a driver, which for the CUPS Snap must be a Printer Application. The first fully working Printer Application for common printers is the PostScript Printer Application, also available in the Snap Store, to be installed via the Snap Store/Software application or by the following command line:

sudo snap install --edge ps-printer-app

The Printer Application will automatically be started as a server daemon and all needed interface connections are done automatically.

Enter the web interface

http://localhost:8000/

Use the web interface to add a printer. Supply a name, select the
discovered printer, then select make and model, or simply “Automatic”, as most of the ~4000 supported printer models get correctly assigned automatically. Also set the loaded
media and the option defaults. If you ar not so lucky and your printer is PostScript but not under these ~4000 models, you can take its PPD file and add it to the Printer Application using the “Add PPD files” button on the front page. This is usually the case when your PPD file is under a proprietary license and so could not be included in free software packages or distributions. Once added, your PPD is also considered by the automatic driver selection. And to see which PPD files in the long list are user-added, they are appropriately marked (and also listed when clicking “Add PPD files” again (then you also can remove the ones you do not need any more). It is also possible to update the PPD for a supported printer simply by adding your own PPD, user-added PPDs are preferred by the automatic driver selection.

Once your PostScript printer is set up in the Printer Application, the CUPS Snap will immediately get note of it and create a CUPS queue.

Now I hope that you have a CUPS queue for your printer and so you should be able to print.

Any classically installed application (distro package or from source) and also classically confined Snaps should print (and otherwise work with CUPS) normally now. This is valid both for user applications with print functionality and also for printer setup tools.

Fully confined Snaps with print functionality print out-of-the-box if they plug the “cups” interface. This is how all such Snaps should be made. Older Snaps from the times before the “cups” interface was created, plug “cups-control”, even if they only want to print. In this case the “cups-control” interface needs to get connected manually. Snaps for printer administration (printer setup tools) must plug “cups-control” and require explicit permission from the Snap Store team if the interface should connect automatically when installing the Snap.

For more advanced operation, like running the CUPS Snap in parallel with the system’s classic CUPS (2 cups daemons on one system and each has its own cups-browsed attached) or managing the PostScript Printer Application with its own command line tool, see the README.md files of the CUPS Snap and of the PostScript Printer Application.

Please tell your experience here in the thread and ask your questions. If you find bugs, report them at the respective projects (all use GitHub): CUPS Snap, CUPS itself, the PostScript Printer Application and its underlying library PAPPL.

News about all this and the state of the art of all the projects you find here.

Happy (snappy) printing!

Till

2 Likes

If you want to test and run into the problem that existing Snaps are still using the “cups-control” interface to just be able to print, here are simple examples to create “correct” Snaps.

Note that I have renamed the slots of the CUPS Snap from printing and admin to cups and cups-control, to do it the standard way as slots have the same names as their respective plugs, as of the discussion here.

I have updated the sample command lines in my initial posting appropriately. If you have already installed the CUPS Snap, please update your CUPS Snap via

sudo snap refresh --edge cups
ubuntu20:~$ sudo snap connect cups:cups-internal cups:cups-control
error: snap "cups" has no plug named "cups-internal"
ubuntu20:~$ snap connections cups
Interface                Plug                          Slot                      Notes
avahi-control            cups:avahi-control            :avahi-control            -
cups                     -                             cups:printing             -
cups                     cups:cups                     -                         -
cups-control             -                             cups:admin                -
cups-control             cups:cups-control             -                         -
home                     cups:home                     :home                     -
network                  cups:network                  :network                  -
network-bind             cups:network-bind             :network-bind             -
network-manager-observe  cups:network-manager-observe  :network-manager-observe  manual
raw-usb                  cups:raw-usb                  :raw-usb                  -
system-files             cups:etc-cups                 :system-files             -

@adasiko Seems that the auto-build on GitHub commits got stopped as they have changed the service. I must find out how to do it under the new service.

No service change, there was an outage on the build servers. The servers are back and I have re-triggered a build of the Snap. Please do

sudo snap refresh --edge cups

again to get the Snap version with my described changes.

@adasiko, it is all working agai, please refresh the Snap and retry.

The last needed interface connections are now approved for auto-connection or not needed any more, so for everyone who installs the CUPS Snap from the Snap Store now, no manual interface connections are needed any more!

I have also updated the initial posting appropriately.

Hi, thx for working on this!

I have one question: is it possible to configure snapd cupsd daemon similarly how one can edit /etc/cups/cupsd.conf on distro package?

Yes, but you have to edit /var/snap/cups/common/etc/cups/cupsd.conf instead and after doing so, restart CUPS with

sudo snap restart cups
1 Like

It’s still running after reboot (without snap CUPS package).

adasiko@ubuntu20:~$ systemctl status cups
● cups.service - CUPS Scheduler
     Loaded: loaded (/lib/systemd/system/cups.service; disabled; vendor preset: enabled)
     Active: active (running) since Thu 2021-03-11 22:11:47 +07; 17s ago
TriggeredBy: ● cups.socket

you’d prbably also want to stop/disable cups.socket here …

The CUPS Snap has a new feature now:

If you share a print queue it is advertised as AirPrint and as Mopria printer. So you can print now from iOS (iPhone, iPad, …) devices and also from Mopria clients (Windows, or Mopria app installed on phone).

As usual, refresh the CUPS Snap via

sudo snap refresh --edge cups

@ogra, thanks, instructions above updated.

1 Like

It’s really hard to kill it permanently :smiley:

sudo systemctl disable cups-browsed
sudo systemctl stop cups-browsed
sudo systemctl disable cups
sudo systemctl disable cups.socket
sudo systemctl stop cups

reboot

> systemctl status cups

● cups.service - CUPS Scheduler
     Loaded: loaded (/lib/systemd/system/cups.service; disabled; vendor preset: enabled)
     Active: active (running) since Sat 2021-03-13 18:14:51 +07; 17s ago
TriggeredBy: ● cups.socket
       Docs: man:cupsd(8)
   Main PID: 829 (cupsd)
      Tasks: 1 (limit: 4654)
     Memory: 6.4M
     CGroup: /system.slice/cups.service
             └─829 /usr/sbin/cupsd -l

мар 13 18:14:51 ubuntu20 systemd[1]: Started CUPS Scheduler.
мар 13 18:14:51 ubuntu20 /hpfax[844]: [844]: error: Failed to create /var/spool/cups/tmp/.hplip

Is it something trigger by connected printer?

> lsusb | grep HP
Bus 001 Device 008: ID 03f0:002a HP, Inc LaserJet P110

@adasiko @ogra probably the safest (but not the correctest) method for testing, at least for the time being until we found the correct way is:

sudo chmod -x /usr/sbin/cupsd
sudo chmod -x /usr/sbin/cups-browsed
sudo systemctl stop cups-browsed
sudo systemctl stop cups

Preventing starting CUPS either manually or via a dependency:

sudo systemctl mask cups

PS: unmask for reverse operation.

@adasiko Does this mean that for switching from the system’s CUPS to the Snap I have to run

sudo systemctl mask cups-browsed
sudo systemctl stop cups-browsed
sudo systemctl mask cups
sudo systemctl stop cups

and that is all to do before installing/starting the CUPS Snap?

Think that some sort of it…

I have HP P1102 over USB in Raspberry Pi with Ubuntu Server 20.04. And Ubuntu Desktop 20.04 in same local network.

Printer had not been found automatically. I added it manually over web interface (just one click in founded list).

Description:	HP LaserJet Professional p1102s Printer
Location:	
Driver:	Local Raw Printer (grayscale, 2-sided printing)
Connection:	dnssd://HP_LaserJet_Professional_P1102%20%40%20ubuntu._ipp._tcp.local/cups?uuid=a24df837-8136-34ed-5ed3-92078c855bc5
Defaults:	job-sheets=none, none media=unknown 

Sent test page from web interface and

Unable to locate printer “ubuntu.local”

Is it some sort of DNS problems? Or may be it has some sort of “bad” drivers (proprietary HP plugins)?
PS: printer works fine from many devices

@adasiko, first, where did you install the CUPS Snap? On the Raspberry Pi? On your Ubuntu Desktop? On both? Which web interface did you use? The one of the CUPS running on your Raspberry Pi? On your desktop? Or of the PostScript Printer Application on your Raspberry Pi?

Note that with the CUPS Snap and the PosyScript Printer Application no proprietary HPLIP drivers or plugins are involved, but if I check on a standard, classic setup with CUPS and HPLIP, your printer model requires the proprietary plugin from HP:

$ lpinfo -m | grep -i P1102
foo2zjs:0/ppd/foo2zjs/HP-LaserJet_Pro_P1102.ppd HP LaserJet Pro P1102 Foomatic/foo2zjs-z2 (recommended)
foo2zjs:0/ppd/foo2zjs/HP-LaserJet_Pro_P1102w.ppd HP LaserJet Pro P1102w Foomatic/foo2zjs-z2 (recommended)
hplip:0/ppd/hplip/HP/hp-laserjet_professional_p1102.ppd HP LaserJet Professional p1102, hpcups 3.21.2, requires proprietary plugin
hplip:1/ppd/hplip/HP/hp-laserjet_professional_p1102.ppd HP LaserJet Professional p1102, hpcups 3.21.2, requires proprietary plugin
hplip:2/ppd/hplip/HP/hp-laserjet_professional_p1102.ppd HP LaserJet Professional p1102, hpcups 3.21.2, requires proprietary plugin
drv:///hpcups.drv/hp-laserjet_professional_p1102.ppd HP LaserJet Professional p1102, hpcups 3.21.2, requires proprietary plugin
hplip:0/ppd/hplip/HP/hp-laserjet_professional_p1102s.ppd HP LaserJet Professional p1102s, hpcups 3.12.2, requires proprietary plugin
hplip:0/ppd/hplip/HP/hp-laserjet_professional_p1102w.ppd HP LaserJet Professional p1102w, hpcups 3.21.2, requires proprietary plugin
drv:///hpcups.drv/hp-laserjet_professional_p1102w.ppd HP LaserJet Professional p1102w, hpcups 3.21.2, requires proprietary plugin
$

Therefore it will not work with the PostScript Printer Application (it is not a PostScript printer). What you have to check is whether it simply works as a driverless (AirPrint, IPP Everywhere, Mopria) printer. In this case the CUPS Snap would pick it up fully automatically.

Could you run the command

driverless

on the Raspberry Pi, where you have connected the printer to USB and post the output here?