-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Dump default AppArmor profile #7599
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
Dump default AppArmor profile #7599
Conversation
Extend the `info` command to dump the default AppArmor profile used by podman. This can be useful to debug AppArmor related issues when the default profile is too tight for the containerized application. The default AppArmor profile is dynamically generated by podman at runtime and, once loaded into the kernel, there's no way to print it in a human-readable form. Signed-off-by: Flavio Castelli <fcastelli@suse.com>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: flavio The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/assign @mheon |
I think that |
@AkihiroSuda @giuseppe @rhatdan WDYT? |
Why don't we ship this as a separate file and not have a built in. Like we do with seccomp.json? |
I think that the profile may have to many runtime deps on the host so it may look slightly different among different hosts. |
The reason nobody ships that as a dedicated file is complicated. This comment provides some background, however I think @cyphar could add more to the discussion as he's the main expert on the topic. |
The I looked into adding something like this to Docker some time ago (moby/moby#33060 (comment) -- this is the comment Flavio linked but I did discuss it elsewhere at the time) but at the time I didn't want to make the internal template public and so tried to implement it without the templating code. Unfortunately this doesn't really work, and we will have to expose the template to users (you need to have a way to detect I can look at implementing this again -- this will also likely tie in with the whole "unification" of AppArmor profiles between Docker/podman/cri-o, so it's as good a chance as any to implement the damn thing.
Yeah that's why we'd need to just save the Go template to disk. It's a bit unfortunate since it's slightly more magical than just a standard AppArmor profile but this is simpler than having a special case for the internal profile. And ultimately most users probably won't need the templating support, but distributions will probably want to make use of it -- if we ever need to give workarounds to customers, templating support would be necessary to be able to 1-for-1 swap out the default profile. |
(I also think adding a feature to print out the profile is a somewhat less elegant workaround for it not being user-configurable in the first place.) |
Well you people will have to handle this, since I am woefully unqualified to work on AppArmor. I can only handle one MAC at a time. |
I've implemented a basic version of the custom AppArmor profile configuration for Docker here. A similar idea could be implemented for podman/cri-o and containerd. |
I think Aleksa's solution is far more elegant. I will close the PR then. |
@cyphar Could you submit a default apparmor profile for Podman/containers-common to ship rather then use the builtin one, making it easier for users to customize? |
Lately I've been struggling a lot to debug an AppArmor related issue: the default profile was too tight for my application (buildah BTW 😄) and I had to find how to relax it.
The default AppArmor profile is dynamically generated by podman at runtime and, once loaded into the kernel, there's no way to print it in a human-readable form. The only way to read the default profile is to start a spelunking session inside of the vendored source code, not fun/doable for the average user 😢
This "issue" is common also with docker, where apparently things are going to get better thanks to this PR.
This draft PR provides a way to let the average user dump the default AppArmor profile. Right now I just added this information to the
podman info
output. OFC this could be moved/changed/dropped... I'm basically looking for your feedback 😄This is an example of the feature in action: