Repository navigation
interfaces: make cups interface implicit on classic - #10023
jhenstridge wants to merge 1 commit into
Conversation
| - core | ||
| deny-connection: | ||
| on-classic: false | ||
| deny-auto-connection: true |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
-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,
- Have the store issue a greedy snap auto-connection rule for the slot side of the
cupssnap for thecupsinterface - this enables a client snap wanting to print that is installed and hasplugs: [cups]to be able to print if thecupssnap is installed without anything extra - Expand our
default-providerlanguage to also work for thecupsplug, such that client snaps can specify that they want thecupssnap 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 thecupssnap) 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
cupssnap 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
cupssnap already installed (i.e. other distros or old ubuntus) gets thecupssnap 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
cupssnap 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 thecupssnap. There may however be situations where a user has some custom printer driver installed that thecupssnap can't use/see, but the locally installed version ofcupsfrom the Fedora rpm repos, etc. can see/use. I think these situations should be minimal and are solvable by improving thecupssnap 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
cupsdo 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.
|
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:
|
|
@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 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 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 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 |
|
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. |
|
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. |
|
I don't see how this interface can achieve its goal if application snaps can't rely on the presence of a With this PR in its current state, we'd have the following:
It's no worse than the status-quo, and provides a good base to make things better. |
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 |
|
I guess looking at the difference between today without an implicit I guess the question about whether we want folks on other distros to need to use the @tillkamppeter do you or the desktop team or the printing stack maintainers of the cups snap intend to support the |
|
@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 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. |
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:
... with the following:
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. |
|
@jhenstridge You are right, the We need the 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. |
|
The ideal solution would be: A Snap which plugs 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 ( 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. |
|
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:
|
|
@pedronis, with the CUPS Snap being used we should always auto-connect the user application Snaps which plug
for these two reasons I am fully in favor of auto-connecting the One additional hint to make the auto-connection safer: Snaps run their apps through the This added So this would be safe if we could make an "auto-connect only if CUPS Snap is installed". |
|
To make this discussion more visible to snapd developers I have posted it into the snapcraft forum. |
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.
|
For posterity's sake I opened #10427 to try an alternative approach to solving this as described on the forum post |
|
This PR is superceded by #10427 |
If we want to convince application snaps that only want to print to switch from the
cups-controlinterface to thecupsinterface, then that interface should be usable on systems without a snapped version of CUPS. Currently that is not possible because there isn't an implicitsystem:cupsslot on classic systems. This PR works to fix that.