cmd/snap-confine: add support for classic confinement #2427

Merged
merged 6 commits into from Dec 7, 2016

Conversation

Projects
None yet
4 participants
Contributor

zyga commented Dec 7, 2016

This branch adds support for classic confinement in snap-confine.

zyga added some commits Dec 2, 2016

Add support for classic confinement
This patch adds support for classic confinement in snap-confine.  The
main idea is that whenever --classic command line option is given the
mount namespace is not unshared. The application executes in the same
mount namespace as all classic applications would. While not strictly
related to the mount namespace, the devices cgroup is not used and PATH
is not reset.

On the snapd side the application will receive different apparmor and
seccomp profiles. The apprmor profile is wide open and the seccomp
profile uses the special "@unrestricted" command to essentially switch
apparmor off entirely.

NOTE: Using classic confinement is incompatible with nvidia driver
sharing as we cannot bind mount anything into /var/lib/snapd/lib/gl but
at the same time the application can just look at /usr/lib/nvidia for
that.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
cmd/snap-confine: add support for classic confinement
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
cmd/snap-confine: add extra comment from jdstrand
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

@zyga zyga added the Critical label Dec 7, 2016

cmd/snap-confine: fix inverted logic
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
cmd/snap-confine/snap-confine.c
- if (group_name == NULL) {
- die("SNAP_NAME is not set");
+ if (!classic_confinement) {
+ /* 'classic confinement' is designed to run without the sandbox
@mvo5

mvo5 Dec 7, 2016

Collaborator

Can we move the comment above maybe? When I first saw the comment I assume it was meant for the following code.

mvo5 approved these changes Dec 7, 2016

Looks good.

cmd/snap-confine: move comment around
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

LGTM

LGTM with one very minor request

+ * - snap-confine skips using device cgroups
+ * - snapd sets up a lenient AppArmor profile for snap-confine to use
+ * - snapd sets up a lenient seccomp profile for snap-confine to use
+ */
@jdstrand

jdstrand Dec 7, 2016

Contributor

Perhaps add a debug() statement here?

cmd/snap-confine: announce classic confinement
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

@zyga zyga merged commit 4af8fa9 into snapcore:master Dec 7, 2016

1 of 5 checks passed

xenial-amd64 autopkgtest running
Details
xenial-i386 autopkgtest running
Details
yakkety-amd64 autopkgtest running
Details
zesty-amd64 autopkgtest running
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@zyga zyga deleted the zyga:snap-confine-simple-classic branch Dec 7, 2016

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