Commit graph

13 commits

Author SHA1 Message Date
Valentin Rothberg 593eb7625a golangci: enable goimports
Enable the goimports linter and fix reports.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-03-05 20:03:44 +01:00
Sascha Grunert c49bc1f176
apparmor: allow receiving of signals from 'podman kill'
In newer kernels, AppArmor will reject attempts to send signals to a
container because the signal originated from outside of that AppArmor
profile. Correct this by allowing all unconfined signals to be received.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-01-24 15:34:47 +01:00
Valentin Rothberg cf1f3191d2 make lint: include unit tests
Include the unit tests (i.e., _test.go files) for linting to make the
tests more robust and enforce the linters' coding styles etc.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-01-14 10:51:59 +01:00
baude db826d5d75 golangci-lint round #3
this is the third round of preparing to use the golangci-lint on our
code base.

Signed-off-by: baude <bbaude@redhat.com>
2019-07-21 14:22:39 -05:00
Sascha Grunert 27ebd7d6f0
Add DefaultContent API to retrieve apparmor profile content
The default apparmor profile is not stored on disk which causes
confusion when debugging the content of the profile. To solve this, we
now add an additional API which returns the profile as byte slice.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-07-18 13:14:02 +02:00
Valentin Rothberg e611176760 pkg/apparmor: fix when AA is disabled
Do not try to load the default profile when AppArmor is disabled on the
host.

Fixes: #3331
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-06-14 17:37:16 +02:00
Valentin Rothberg 18b7009754
apparmor: don't load default profile in rootless mode
AppArmor requires root privileges, so skip loading the default profile
in rootless mode.  Also add a log to ease debugging.

Fixes: #2223
Reported-by: @dmacvicar
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-01-29 10:38:52 -05:00
Valentin Rothberg edb285d176 apparmor: apply default profile at container initialization
Apply the default AppArmor profile at container initialization to cover
all possible code paths (i.e., podman-{start,run}) before executing the
runtime.  This allows moving most of the logic into pkg/apparmor.

Also make the loading and application of the default AppArmor profile
versio-indepenent by checking for the `libpod-default-` prefix and
over-writing the profile in the run-time spec if needed.

The intitial run-time spec of the container differs a bit from the
applied one when having started the container, which results in
displaying a potentially outdated AppArmor profile when inspecting
a container.  To fix that, load the container config from the file
system if present and use it to display the data.

Fixes: #2107
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-01-09 22:18:11 +01:00
Valentin Rothberg 9563f31437 pkg/apparmor: use a pipe instead of a tmp file
Use a pipe instead of a temporary file to load the apparmor profile.
This change has a measurable speed improvement for apparmor users.

Signed-off-by: Valentin Rothberg <vrothberg@suse.com>

Closes: #1262
Approved by: mheon
2018-08-14 14:25:14 +00:00
Valentin Rothberg 973c9e6ba6 pkg/apparmor: move data under Linux/apparmor buildtags
Move all Linux-related data under the corresponding buildtags to reduce
the memory footprint and speed up compilation for non-apparmor builds.

Signed-off-by: Valentin Rothberg <vrothberg@suse.com>

Closes: #1262
Approved by: mheon
2018-08-14 14:25:14 +00:00
Valentin Rothberg 31e0dea5a0 pkg/apparmor: move all linux-code into apparmor_linux*
For easier maintenance and clearer structure of the code.

Signed-off-by: Valentin Rothberg <vrothberg@suse.com>

Closes: #1262
Approved by: mheon
2018-08-14 14:25:14 +00:00
Valentin Rothberg 8569ed0305 AppArmor: runtime check if it's enabled on the host
Check at runtime if AppArmor is enabled on the host.

Signed-off-by: Valentin Rothberg <vrothberg@suse.com>

Closes: #1128
Approved by: mheon
2018-07-23 18:11:09 +00:00
Valentin Rothberg 06ab343bd7 podman/libpod: add default AppArmor profile
Make users of libpod more secure by adding the libpod/apparmor package
to load a pre-defined AppArmor profile.  Large chunks of libpod/apparmor
come from github.com/moby/moby.

Also check if a specified AppArmor profile is actually loaded and throw
an error if necessary.

The default profile is loaded only on Linux builds with the `apparmor`
buildtag enabled.

Signed-off-by: Valentin Rothberg <vrothberg@suse.com>

Closes: #1063
Approved by: rhatdan
2018-07-11 16:36:24 +00:00