Skip to content

interfaces: make cups interface implicit on classic - #10023

Closed
jhenstridge wants to merge 1 commit into
canonical:masterfrom
jhenstridge:cups-iface-implicit-on-classic
Closed

jhenstridge wants to merge 1 commit into
canonical:masterfrom
jhenstridge:cups-iface-implicit-on-classic

Conversation

@jhenstridge

Copy link
Copy Markdown
Contributor

If we want to convince application snaps that only want to print to switch from the cups-control interface to the cups interface, then that interface should be usable on systems without a snapped version of CUPS. Currently that is not possible because there isn't an implicit system:cups slot on classic systems. This PR works to fix that.

@pedronis
pedronis self-requested a review March 10, 2021 13:26
- core
deny-connection:
on-classic: false
deny-auto-connection: true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest (if I understand the code correctly) here to use

deny-auto-connection: false

as we are introducing the cups interface so that application Snaps with print functionality (like LibreOffice) plug to cups and this gets auto-connected as it does not allow admin tasks on CUPS. Only cups-controlallows admin tasks and therefore should only auto-connect with permission from the Snap Store team.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left this out of the initial PR so the base declaration would match that of cups-control. I agree that it would be good to have a conversation about loosening the restrictions for the cups slot, although I'm not sure if it should be in this PR.

At most, I think we'd want to a rule similar to the x11 and wayland slots to allow auto connection on classic systems:

deny-auto-connection:
  on-classic: false

One issue to consider though is how many systems are there where cups gives meaningfully less access than cups-control?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If CUPS is the CUPS Snap then there is always the difference, if CUPS is classically installed from Ubuntu's packages, the CUPS daemon does exactly the same checks, so if the client is a fully confined Snap and plugs only cups and not cups-control cupsd rejects administrative inquiries.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What we want to have is that if someone uploads a Snap to the Snap Store and it plugs cups, the cups interface should auto-connect to both the system's and the CUPS Snap's cups slot on a user's system automatically, without that the uploader of the Snap needs to request permission from the Snap Store team.

Only if the uploaded Snap plugs cups-control the auto-connection (to both the system's and the CUPS Snap's cups-control slot) on the user's system should only happen if the uploader got permission from the Snap Store team.

This is a protection against malicious Snap Store uploads which mess with a user's printers and jobs whereas the common case of an application with which you can print is handled automatically without need of the intervention of the Snap Store team.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can tell, the cups-control restrictions currently only exist in Ubuntu >= 20.10 and the snap. None of the LTS releases (where the majority of our users are) carry the patches. I agree that we might want to loosen the restrictions in the future, but for now it looks cups carries the same risks as cups-control for the vast majority of users.

I think it is more important to have the slot available soon, and then tackle permissions later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree - even if we SRU this support back to the LTS releases, this still leaves all non-Ubuntu users at risk if their classic cups cannot perform the snap mediation - so for now I think it is best to keep cups with deny-auto-connection: true - OR the only other option I can think is that if snapd was somehow able to detect that the locally installed cups was able to perform the mediation then it would auto-connect cups in that case but I feel this is likely too complicated and therefore fraught so would prefer we stick to the current situation of having cups be manually connected.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snapd could check whether the running CUPS is "secure" (having snap mediation) as there are tasks which CUPS considers administrative but do not change configuration, as lpinfo -v or cupsctl, so snapd could check the installed CUPS before deciding to auto-connect the cups interface.

@anonymouse64 anonymouse64 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 on this PR, I understand the intention of more widely providing snaps the ability to use the less privileged cups interface, but I don't think making this interface implicit and also auto-connecting is the right way to go (though maybe it could be made implicit without adding auto-connection, but I think doing that complicates the way forward as I describe below).

The issue as I see it is that the cups interface provides access to the cups socket, which will only be performing mediation if the version of cupsd listening on that socket is very new or the snap version AIUI (please correct me if other distros are carrying patches etc to perform mediation and I will adjust my stance correctly). This means that on systems without a new cups version, if a snap connects to the cups socket via the cups interface, it gets full admin level access to configure drivers and all the other "dangerous" things we associated with cups-control and never handed out via auto-connection of cups-control. This is not desirable, and is a security regression, if we were okay with providing the cups-control admin access to any snap, then we should have just made cups-control auto-connect and not have done all the work we did with cups...

I think what we want instead is to have the cups snap provide a slot of the cups interface, and have that slot specifically from the cups snap auto-connect to any snap that plugs the cups interface. This ensures that when a client snap gets the auto-connection of the cups interface, we know 100% for sure that the version of cupsd on the other side of the socket we are providing access to is indeed one that performs snap mediation, and thus only grants printing access and not admin access to client snaps that only have their cups plug connected and don't have a cups-control plug connected.

The way I think to accomplish this is 2-fold,

  1. Have the store issue a greedy snap auto-connection rule for the slot side of the cups snap for the cups interface - this enables a client snap wanting to print that is installed and has plugs: [cups] to be able to print if the cups snap is installed without anything extra
  2. Expand our default-provider language to also work for the cups plug, such that client snaps can specify that they want the cups snap to be installed if it isn't already installed and can thus then rely on the fact that this snap will always print (without the user doing weird unexpected things like disconnecting auto-connected interfaces) through a version of cupsd (i.e. the one from the cups snap) that performs snap mediation, and is secure, and always works.

This results in the following user behavior which I think is desirable:

  • A user with the cups snap already installed (i.e. new ubuntu installs AIUI) gets to do basic printing from a client snap without connecting any interfaces
  • A user without the cups snap already installed (i.e. other distros or old ubuntus) gets the cups snap installed when they go to install a snap that wants to be able to print
  • Snaps can be verified to always be able to print so long as the cups snap stays up to date and is able to connect/use as many printers as possible, since now every snap will be printing using the version of cupsd from the cups snap. There may however be situations where a user has some custom printer driver installed that the cups snap can't use/see, but the locally installed version of cups from the Fedora rpm repos, etc. can see/use. I think these situations should be minimal and are solvable by improving the cups snap which can be updated out-of-band from i.e. Fedora rpm repos and thus is a better user story I think.
  • We, as snapd architects, can have strong confidence knowing that snap applications which use cups do not have full admin access to cupsd

Number 2 above however implies that making the cups interface implicit creates a problem for auto-connecting to the version of the cups interface from the cups snap, since now there are multiple candidates to auto-connect. I think this could hypothetically be solved with more complicated snap-declaration assertions, but I think it is a cleaner solution to implement something like default-provider for the cups interface. That would also be more useful for other interfaces like docker and some mir/wayland/kiosk thing I can't remember at the moment.

@anonymouse64 anonymouse64 added ⛔ Blocked Needs Samuele review Needs a review from Samuele before it can land labels Mar 12, 2021
@tillkamppeter

Copy link
Copy Markdown

So this means in short that the only slot for the "cups" interface should be provided by the CUPS Snap and if a Snap which prints (and plugs "cups" for it) is installed it should pull the CUPS Snap as a "dependency" (so that the Snap connects to the CUPS Snap and only prints through the CUPS Snap)?

If the user action of installing a Snap force-installs the CUPS Snap we have two scenarios how to actually install the CUPS Snap:

  1. Leave the original classically installed CUPS intact and running and install the CUPS Snap right away. This makes the Snap's cupsd running on port 10631 and on the socket /var/snap/cups/common/run/cups.sock. To assure that the Snap prints on this cupsd it has to run the command cups.lpstat -H to get the CUPS Snap's socket (independent whether the CUPS Snap actually runs this way inparallel to a classic CUPS). Advantage: By sharing the print queues of the classic CUPS the snapped CUPS picks them up and so the user can print on a printer with unsnappable driver. Disadvantage: It is confusing to have 2 cupsd processes and each with its own attached cups-browsed running on a production system. Especially snapped apps print through the snapped CUPS and unsnapped apps print through the unsnapped CUPS.
  2. Deactivate the original classically installed CUPS and then install the CUPS Snap (this sequence could be done by a migration script, added to the CUPS Snap). Then only the snapped cupsd is running on the standard port 631 and the standard socket /var/run/cups/cups.sock. Advantage: Easily understandable setup where everythinh prints through the same CUPS daemon, as a user expects. Disadvantage: Classically installed drivers are not supported. We need to convert all drivers to Printer Application Snaps which takes time and/or GSoC students. We also need a migration script (which is the least amount of work here).

@jhenstridge

Copy link
Copy Markdown
Contributor Author

@anonymouse64: I explicitly left the issue of auto-connection off the table with this PR: the changes to the base declaration here just bring it into line with cups-control, which also does not allow auto-connect. I know Till would like to see this interface auto-connect, but I don't think that behaviour would be appropriate for the implicit slot as outlined in the previous discussion.

It's not clear to me that running two copies of CUPS on a system would be desirable: how would users be expected to configure the second instance, and would they now need to monitor two print queues? There are a number of global resources CUPS wants to own (the /run/cups/cups.sock unix socket and port 631 TCP socket) that would make it difficult to run two in parallel.

If we take it as a given that a system will be running either a CUPS from the host system or the snap but not both, then the current status-quo means applications cannot depend on a cups slot being present. If that's how we leave things, then the interface seems pretty pointless.

This isn't the only case where we have interfaces that describe behaviour that we can't enforce on all systems either. An obvious example is the dual audio-playback / audio-record interfaces. Outside of Ubuntu releases, these two interfaces are equivalent. But it is still useful for applications to indicate what level of access they require and enforce it where we can. I don't think it would be an improvement if anaudio-playback slot was only available on Ubuntu systems.

@anonymouse64

Copy link
Copy Markdown
Contributor

I guess I don't see the utility of adding an implicit cups slot that doesn't auto-connect, in this case the cups interface becomes exactly the same as the cups-control interface we already have today that users can manually connect anywhere regardless of how cups is installed and be able to print. Is the intention really that we add the implicit slot just to then have to document that users on distros other than Ubuntu still have to go either manually install the cups snap or provide full printing administration permission to their snap? It seems it would be confusing for a user to document that in order for them to print something from a strict snap they need to provide this permission to the snap on some distros but not other ones.

Also I'm now confused about the presence of cupsd as a snap vs cupsd on the host, I understood it that they could co-exist but it seems they cannot? This is also unfortunate but I suppose is to be expected considering we again have the same problem of the cups interface trying to share a global resource that we don't really know where it is coming from.

Lastly is it not the goal of the cups snap to eventually be able to provide "classically installed printer drivers"? I grant that it may be confusing to users to have multiple instances of cupsd running but if the snap version of cupsd isn't able to do everything that the users classic version of cupsd can do that also seems not great.

@tillkamppeter

Copy link
Copy Markdown

One idea of confined Snaps are that they are distribution-independent. We need to keep it this way.

For me the best solution to give good user experience and secure printing is that the classically installed CUPS gets replaced by the CUPS Snap and client Snaps auto-connect their "cups' plug to the CUPS Snap's "cups" slot. For this I have to get the classic drivers which typically come with a distribution into Printer Applications. Most for that I have done, the code is in the PostScript Printer Application. This can be completed in a reasonable amount of time, before Ubuntu 21.10. I do not want 2 CUPS daemons on one production system, this option of the Snap was intended for development only. I would rather introduce some kind of universal retro-fitter Printer Application for the last stubborn needs of classic drivers. An admin can retro-fit a driver with it but thousands of end users are not required to hassle with manual interface connections of snapped applications to unsnapped CUPS.

In contrary waiting with auto-connection of the "cups" plug until we have a secure universal "cups" slot also covering classic CUPS can take years. I have merged a Snap mediation code into upstream CUPS (after Apple's 1-year ignorance on CUPS upstream we (Michael Sweet and me) have moved its upstream into OpenPrinting and Michael has asked me to push Snap support into it). I can also make it used by default (I can directly push into CUPS now). But, once, not every distro will actually use it, as it introduces new dependencies for the CUPS package, libapparmor and libsnapd-glib, in turn pulling in glib. Also, if today all distros activate Snap mediation in their CUPS, support live times of released distros take years to terminate.

So what I like to see is that the CUPS Snap is used as the system's CUPS, the confined application Snaps auto-connect their "cups" plug to the CUPS Snap's "cups" slot, and all drivers are moved into Printer Applications. Therefore my priority for now is retro-fitting the available classic drivers and push forward a user-friendly migration from classic CUPS to the CUPS Snap.

@jhenstridge

Copy link
Copy Markdown
Contributor Author

I don't see how this interface can achieve its goal if application snaps can't rely on the presence of a cups slot. It would be nice if it would be auto-connectable, but I don't see that as a hard requirement.

With this PR in its current state, we'd have the following:

  1. If applications use a cups plug instead of cups-control, then they won't be able to use the administrative APIs if they want to function on Ubuntu systems (currently just Hirsute, but presumably earlier versions too once the patch gets backported). For non-malicious snaps, that should provide some level of assurance even for systems which don't impose the restrictions (same as for audio-playback/audio-record).

  2. No matter what the base declaration says, the store could provide an assertion allowing auto-connection for the slot provided by the CUPS snap.

It's no worse than the status-quo, and provides a good base to make things better.

@tillkamppeter

Copy link
Copy Markdown

No matter what the base declaration says, the store could provide an assertion allowing auto-connection for the slot provided by the CUPS Snap.

Yes, we need to get an auto-connection to the "cups" slot of the CUPS Snap, and as long as we cannot do an automated test on an unsnapped CUIPS (like do cupsctl from a confined Snap plugging only to "cups") leave the plugging the client's "cups" to the system's "cups" slot (= slot for unsnapped CUPS) on manual connection.

@anonymouse64

Copy link
Copy Markdown
Contributor

I guess looking at the difference between today without an implicit cups system slot and the world with this PR merged, if folks install a snap which uses the cups plug on a distro other than Ubuntu, then they need to also manually install the cups snap, and folks are saying this is undesirable? From @tillkamppeter's comments about adding more support to cups, it seems like having folks install the cups snap on other distros is a net good thing, in that the snap will be more likely to work given that the cupsd it is talking to will be one that is tested and supported by us on Ubuntu and the application that is trying to print is also effectively built/running on Ubuntu via the base snaps.

I guess the question about whether we want folks on other distros to need to use the cups snap to print things is the crux of the question to me, I had thought this was the intention because it provides better security and a better maintenance story for snaps wishing to print, and it also brings nice things like being able to install printer drivers which only are "supported" for older distros as the printer drivers can be built on top of base snaps for example, and the version of cupsd from the cups snap can be updated more frequently than the version in the distro's packaging (though maybe not for like Arch for example). And finally I also thought that two versions of cupsd could co-exist in that snap applications can print things using the snap cupsd and non-snap applications can print things using the non-snap cupsd, but it appears that maybe isn't desirable.

@tillkamppeter do you or the desktop team or the printing stack maintainers of the cups snap intend to support the cups snap on other distros and additionally what is the plan around installing the cups snap on a distro that has a classically installed cupsd? I think if the team intends to maintain the snap and support it for other distros like this and has a reasonable plan to handle UI for what happens when the cups snap is installed on other distros and there is an existing classic cupsd (whether that be running two instances of cupsd or having the cups snap version take over from the classically installed version), then I am still -1 on making the cups interface implicit. If the team doesn't intend to support this scenario or has no technical plan/time/UI to make a nice experience for installing the cups snap on a distro with an existing classically installed cupsd, then I guess I am +1 on making the cups interface implicit, but still not auto-connect it and I guess we have to live with the fact that on other distros you have to manually connect the interface.

@tillkamppeter

Copy link
Copy Markdown

@anonymouse64 the CUPS Snap is not a Ubuntu-only project, it is an OpenPrinting project, as CUPS upstream also is. So it is intended for all distributions, not only for Ubuntu. Also Printer Applications, the new format for printer drivers, are for all distributions, to provide manufacturer's and other driver developers to cover all distributions with minimum effort.

Creator and maintainer of the CUPS Snap is me, working closely together with Michael Sweet, author of CUPS.

To ease the development of the Snap I have designed it from the beginning on to run in parallel to an already installed classic CUPS. The Snap contains a cupsd with its cups-browsed attaching to it. Sharing the print queues of one daemon makes them available to the other. Originally I did not intend this mode for production, but perhaps if one carefully organizes things one could even go this way on production systems.

Imagine the cupsd of the Snap being the firewall for the classically installed cupsd. A client Snap gets only access to the snapped cupsd. The snapped cupsd has no own queues but its cups-browsed picks up the queues from the classic cupsd. Then all jobs would get processed and send off to the printers by the classic cupsd, but the classic cupsd only receives jobs from the classic applications, the snapped applications print to the snapped cupsd, and the snapped cupsd passes the jobs through to the classic cupsd. The snapped apps cannot admin any cupsd this way, the snapped one using mediation and the classic one totally inaccessible for the snapped application.

Drivers in Printer Application Snaps and driverless IPP printers would be connected from the classically installed cupsd, tghis cupsd also accepts classically installed (proprietary or not yet snapped) drivers.

Important for this scenario would be that snapped client apps auto-connecting their cups plug to the snapped cupsd's cups slot only talk with the snapped cupsd, independent on which port and socket it is running. For this the application Snap could run all its apps through a wrapper script, which runs cups.lpstat -H and sets the CUPS_SERVER environment variable to the result of this command.

Another, "cleaner" scenario is to run the CUPS Snap alone, which requires to have all drivers in Printer Applications. This would be much more easily debuggable and distros do not need to package CUPS anymore, there will be one CUPS for everyone right from OpenPrinting, from upstream.

@jhenstridge

Copy link
Copy Markdown
Contributor Author

I guess looking at the difference between today without an implicit cups system slot and the world with this PR merged, if folks install a snap which uses the cups plug on a distro other than Ubuntu, then they need to also manually install the cups snap, and folks are saying this is undesirable?

Yes, I would say that is undesirable. With my application developer hat on, you're proposiing that we move from the current status quo of:

  • Add a cups-control plug to my snap
  • Request a store have the plug auto-connect, or document that users will need to manually connect the slot with snap connect in order for printing to work.

... with the following:

  • Add a cups plug to my snap
  • Document that users must disable or remove a core subsystem of their operating system, and replace it with a snapped version that will likely have no support from the distribution vendor if they are not on Ubuntu.
  • Require users to set up their print queues all over again. This may be relatively straight forward for networked IPP printers, but could be non trivial for printers requiring vendor drivers.

This is a massive amount of friction compared to what we do now, and seems out of line with how we treat other services provided by the host.

@tillkamppeter

Copy link
Copy Markdown

@jhenstridge You are right, the cups plug has no advantage at all in a system with neither the CUPS Snap being the standard printing environment nor an Ubuntu-Hirsute-or-newer-packaged classic CUPS.

We need the cups/cups-control perhaps already be done before the production CUPS.

As you need a cupsd to identifywhether an inquiry is administrative, you will probably need a firewall CUPS as I mentioned earlier, but more lightweight, not with a big Ghostscript and cups-filters-carrying CUPS Snap.

Or one needs some way that application Snaps could drop their group privileges, even if the user is in the groups "adm" and "lpadmin" the application Snap acts as the user not being in these groups. Is this possible? Then CUPS' original protection method against administrative inquiries would apply, and this method CUPS had from the beginning on.

@tillkamppeter

Copy link
Copy Markdown

The ideal solution would be:

A Snap which plugs cups (and has it connected) but does not plug cups-control (or has it not connected) runs a wrapper around each of its apps which drops any administrative group membership privileges. For CUPS these are the "lpadmin" and "adm" groups ("adm" is used only by the CUPS Snap in systems which do not have "lpadmin", but in this case cupsd has Snap mediation), so for non-Snap CUPS only "lpadmin".

Or in general, one could create a new system (implicit) interface named "admin" (this is not CUPS-specific) and for a fully confined Snap being allowed to run its apps with any system group (GID < 1000) privileges it needs to plug this interface to the system's "admin" slot (:admin). This does only get auto-connected with permission of the Snap Store team. This does not only protect against admin inquiries on CUPS but also on any other system component.

If there are system groups for non-admin purposes, appropriate (auto-connecting) interfaces could permit their privileges to the apps in the Snap.

In the CUPS/printing case, a Snap which is supposed to manage CUPS would have to plug the "admin" interface. Only then it can manage any CUPS, classic, snapped, with or without mediation. If it does not plug "admin" t cannot manage CUPS, even a completely "naked" one. Then "cups-control" is only relevant for snapped CUPS (or we let "cups-control" be what it is now plus opening up use of "lpadmin" group privileges to this way allow admin of "naked" CUPS without plugging "admin").

A purely printing Snap plugs "cups" but neither "cups-control" nor "admin" and so it runs its apps with dropped "lpadmin" (and dropped any system group) privileges, making admin inquiries being rejected by all types of cupsd but printing inquiries accepted.

@pedronis

Copy link
Copy Markdown
Contributor

I discussed this more with @jhenstridge. I think adding the implicit plug is OK but about auto-connection as people mentioned it can't be turned on in general:

  • it could be turned on on-classic for specific distros at a later point
  • about the snap, it's a bit unclear to me whether it should auto-connect, at least initially, given that it sounds that using it would need anyway manual intervention like turning off the host cups

@pedronis
pedronis removed their request for review March 18, 2021 13:34
@tillkamppeter

Copy link
Copy Markdown

@pedronis, with the CUPS Snap being used we should always auto-connect the user application Snaps which plug cups as

  • The CUPS Snap has always Snap mediation, so auto-connection with the CUPS Snap is always safe
  • Currently, where we are still in the phase of testing, users have to de-activate CUPS before installing the CUPS Snap. As soon as we say that the CUPS Snap will be default in Ubuntu I will add a migration script, which will not only move over the CUPS configuration but also stop/disable/remove classic CUPS (as far as possible out of a Snap, otherwise Ubuntu's release updater will probably have to do this job).

for these two reasons I am fully in favor of auto-connecting the cups interface when the CUPS Snap is installed.

One additional hint to make the auto-connection safer:

Snaps run their apps through the snapcraft-runner script to set things like LD_LIBRARY_PATH, PATH, ... It could have something like this at the end:

[...]
if which cups.lpstat > /dev/null; then
  export CUPS_SERVER=`cups.lpstat -H`
fi
exec "$@"

This added if statement tells the libcups functions in the application to use the socket of the snapped cupsd (by determining the socket with the CUPS Snap's lpstat and setting the CUPS_SERVER environment variable with it). So independent whether the CUPS Snap is installed alone or in parallel to the system's CUPS the application always prints to the Snap and the Snap has Snap mediation.

So this would be safe if we could make an "auto-connect only if CUPS Snap is installed".

@tillkamppeter

Copy link
Copy Markdown

To make this discussion more visible to snapd developers I have posted it into the snapcraft forum.

tillkamppeter added a commit to OpenPrinting/cups-snap that referenced this pull request Apr 9, 2021
Following the discussion here

canonical/snapd#10023 (comment)

https://forum.snapcraft.io/t/handling-of-the-cups-plug-by-snapd-especially-auto-connection/23419/3?u=till.kamppeter

I am implementing Ian Johnson's suggestion (see second link) to solve
the problem of a confined application Snap only being able to print
but not to be able to do administrative tasks on the system's CUPS
when the application Snap only plugs "cups" (which auto-connects by
default) and not "cups-control" (which only auto-connects with
permission of the Snap Store team).

If the system's CUPS is this CUPS Snap or a the CUPS package of a
current Ubuntu distribution, there is a Snap mediation in cupsd which
checks if an incoming request is administrative, whether it comes from
a confined Snap or not and in the former whether it plugs
"cups-control", before accepting it. So in these cases the security
concept works amd allows arbitrary developers to upload application
which print to the Snap Store and users are protected against
administrative tasks performed on their CUPS by these applications,
even if the user is in the "lpadmin" group (usually the first created
user on Ubuntu is).

Now if we take an old Ubuntu or a non-Ubuntu distribution (everything
where one can install snapd on, usually everything where PID 1 is
systemd) then we have a CUPS without Snap mediation, so we restrict
the "cups" interface to the domain socket of this CUPS Snap and make
the installation of a Snap which plugs "cups" install this CUPS Snap
as a dependency (default-provider).

But forcing the use of the CUPS Snap for printing from snapped
applications and continuing with the original system's CUPS for
unsnapped applications causes user confusion and users cannot print
with their classic (often proprietary) printer drivers.

So to make everything transparent and consistent, we let this CUPS
Snap run as a proxy for the system's classic CUPS when it is installed
on a system which has a classic CUPS installed (determined by the
presence of an /etc/cups/cupsd.conf file). In this case it runs a
special auxiliary daemon (cups-proxyd, part of this Snap, NOT
cups-browsed) which mirrors all ths queues of the system's classic
CUPS to the CUPS of this Snap and on the Snap configures them tompass
the jobs through to the system's classic CUPS unfiltered, so that
drivers are used there.

So an application Snap plugging "cups" cannot touch the system's CUPS
at all and any administrative tasks issued by it are blocked by the
Snap mediation of the snapped CUPS (so it also cannot mess up the
snapped CUPS). The snapped CUPS only grabs queues and copies PPDs (to
make the options available to the client) from the system's CUPS and
sends jobs to the system's CUPS. Only an application Snap plugging
"cups-control" interacts directly with the system's CUPS.

If there is no classic CUPS (no /etc/cups/cupsd.conf), then the Snap
acts as a standalone system CUPS and also starts cups-browsed. It
listens on the standard domain socket and port then and so all
(snapped and unsnapped) applications print on this CUPS. As the
snapped CUPS has Snap mediation it does not need to be protected by
another proxy CUPS.

If you want to use the old way of this Snap's CUPS running as an
independent second CUPS daemon in parallel to the system's classic
CUPS, as this Snap did before when there is a classic CUPS already,
you need to simply run

sudo touch /var/snap/cups/common/no-proxy

to block the proxy mode. Remove the file again to enable the proxy
mode again. You need to stop the CUPS Snap and start it again for this
to take effect:

sudo snap stop cups
sudo snap start cups

Note that this mode is NOT RECOMMENDED FOR PRODUCTION. It is not
tested much and two independent instances of cupsd are confusing for
users.
@anonymouse64

Copy link
Copy Markdown
Contributor

For posterity's sake I opened #10427 to try an alternative approach to solving this as described on the forum post

@anonymouse64

Copy link
Copy Markdown
Contributor

This PR is superceded by #10427

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⛔ Blocked Needs Samuele review Needs a review from Samuele before it can land

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants