-
Notifications
You must be signed in to change notification settings - Fork 587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
o/hookstate/ctlcmd: add optional --pid and --apparmor-label arguments to "snapctl is-connected" #9132
o/hookstate/ctlcmd: add optional --pid and --apparmor-label arguments to "snapctl is-connected" #9132
Conversation
CUPS is supposed to allow access from any non-snapped process and any classic-mode-snapped process in addition to standard-snapped processes plugging to "cups-control", so either the mentioned command should return "true" in all these cases or have special answers for non-snapped and classic-mode-snapped processes. |
Is it also possible for CUPS to do this with an API call or only by calling this command line tool? |
d972a2b
to
9e06d76
Compare
Good point about classic confinement snaps. I agree that for the Pulse Audio and CUPS use cases it would make sense to treat classic snaps like unconfined processes. It does muddy things a bit though, since classic snaps can have plugs and slots.
Yes. The snapd-glib library includes a Since you'd be dealing with only a process ID, this would remove the need for determining and parsing the AppArmor label of the peer too. |
9e06d76
to
2c2e8e2
Compare
2c2e8e2
to
ee670df
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this looks correct and feels nice.
I left some comments. Please ping for a full review when not a draft.
ee670df
to
260dff9
Compare
74e395e
to
f02503d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick pass through the spread test (my favourite part of snapd patches)
819ab76
to
f10bd08
Compare
@jhenstridge, anything still missing to drop the "Draft" status? I am waiting for this to get in, so that the CUPs Snap can finally get into the Snap Store. |
I've flipped the PR over to ready for review. I added a check to restrict the feature to one of a few slot types. That check probably should be changed a bit or moved to a more appropriate location, but I'm not sure where exactly. |
@jhenstridge I looked at this and spent some time thinking, let's chat about it |
d9f68cb
to
722e2c3
Compare
722e2c3
to
d90122e
Compare
This looks good to me from a security point of view, there are comprehensive tests and the implementation looks solid. Just waiting to follow up on Samuele's question above before signing off on this with security review. |
Security review done as per the previous comments / discussion 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, a couple of comments/questions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jhenstridge I answered to your last replies making some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a couple terminology changes to use more inclusive language, but other than that lgtm, thanks for working on this
bfba67b
to
90587ed
Compare
…4.04 These tests rely on the ability to identify the snap a process ID belongs to, which means either (a) the systemd or unified cgroup name includes the snap name, or (b) the freezer cgroup includes the snap name. On Ubuntu 14.04, processes are not tracked via systemd so (a) fails. And snap-confine does not add classic confined processes to a freezer cgroup, so (b) fails as well. We're still runing the parts of the test that deal with strict confined snaps, since that functions correctly on 14.04.
90587ed
to
f3c91c9
Compare
This PR is an implementation of @pedronis's
snapctl is-connected --pid
proposal described in this forum thread:https://forum.snapcraft.io/t/autoconnect-requests-for-pulseaudio/18926/3?u=jamesh
Unlike regular
snapctl is-connected
, the--pid
option only considers connections with the snap identified by the given process ID, as identified bycgroup.SnapNameFromPid
. The intention is to allow a snap daemon using local sockets check that the peer it is talking to has connected a given interface.For example, a Pulse Audio snap may provide
audio-record
andaudio-playback
slots whose connection grant access to the daemon's socket. The daemon can issue asnapctl is-connected --pid $pid audio-record
to determine whether a particular client has been granted access to the microphone.In addition to the normal 0/1 exit codes, the command may also return the following:
These both look like "false" to the shell, but can be used by services that want to communicate with host system processes or classic snaps.
There is a placeholder function to check whether to allow the feature to be used with a particular plug/slot. At present, it hard codes it to allow use on slots of interface
cups-control
,pulseaudio
, oraudio-record
.