Commit Graph

22 Commits

Author SHA1 Message Date
Paul Holzinger 78b419909b Enable more golangci-lint linters
Cleanup the golangci.yml file and enable more linters.

`pkg/spec` and `iopodman.io` is history. The vendor directory
is excluded by default. The dependencies dir was listed twice.

Fix the reported problems in `pkg/specgen` because that was also
excluded by `pkg/spec`.

Enable the structcheck, typecheck, varcheck, deadcode and depguard
linters.

[NO TESTS NEEDED]

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-02-12 18:20:28 +01:00
Daniel J Walsh 9ebde6e03a
Containers should not get inheritable caps by default
When I launch a container with --userns=keep-id the rootless processes
should have no caps by default even if I launch the container with
--privileged.  It should only get the caps if I specify by hand the
caps I want leaked to the process.

Currently we turn off capeff and capamb, but not capinh.  This patch
treats capinh the same way as capeff and capamb.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-07 05:53:07 -05:00
OpenShift Merge Robot ffe2b1e95a
Merge pull request #8685 from mheon/ignore_containersconf_sysctls_shared_net
Ignore containers.conf sysctls when sharing namespaces
2021-01-05 17:08:31 -05:00
Max Goltzsche bd35792b0c
fix: disable seccomp by default when privileged.
When running a privileged container and `SeccompProfilePath` is empty no seccomp profile should be applied.
(Previously this was the case only if `SeccompProfilePath` was set to a non-empty default path.)

Closes #8849

Signed-off-by: Max Goltzsche <max.goltzsche@gmail.com>
2021-01-02 01:38:19 +01:00
Josh Soref 4fa1fce930 Spelling
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2020-12-22 13:34:31 -05:00
Matthew Heon 46183cf873 Ignore containers.conf sysctls when sharing namespaces
The existing code prevents containers.conf default sysctls from
being added if the container uses a host namespace. This patch
expands that to not just host namespaces, but also *shared*
namespaces - so we never modify another container's (or a pod's)
namespaces without being explicitly directed to do so by the
user.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-12-10 11:43:59 -05:00
Daniel J Walsh 1ace9e3ba6
Properly handle --cap-add all when running with a --user flag
Handle the ALL Flag when running with an account as a user.

Currently we throw an error when the user specifies

podman run --user bin --cap-add all fedora echo hello

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-12-09 14:21:16 -05:00
Giuseppe Scrivano afa4ec0db0
specgen: keep capabilities with --userns=keep-id
if --userns=keep-id is specified and not --user is specified, take the
unprivileged capabilities code path so that ambient capabilities are
honored in the container.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-11-02 15:46:56 +01:00
Giuseppe Scrivano 6a94429098
specgen: fix check for root user
if the username is specified in the USER:GROUP form, make sure we only
check for USER.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-11-02 14:39:02 +01:00
Giuseppe Scrivano bce8f851c1
specgen: add support for ambient capabilities
if the kernel supports ambient capabilities (Linux 4.3+), also set
them when running with euid != 0.

This is different that what Moby does, as ambient capabilities are
never set.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-11-02 14:36:39 +01:00
Giuseppe Scrivano 703381b4a2
capabilities: always set ambient and inheritable
change capabilities handling to reflect what docker does.

Bounding: set to caplist
Inheritable: set to caplist
Effective: if uid != 0 then clear; else set to caplist
Permitted: if uid != 0 then clear; else set to caplist
Ambient: clear

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-09-30 15:14:07 +02:00
Daniel J Walsh 0d70df1195
Ignore containers.conf sysctl when namespaces set to host
If user sets namespace to host, then default sysctls need to be ignored
that are specific to that namespace.

--net=host ignore sysctls that begin with net.
--ipc=host ignore fs.mqueue
--uts=host ignore kernel.domainname and kernel.hostname

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-09-28 16:17:28 -04:00
Sascha Grunert 1509adc0a7
Fix unconfined AppArmor profile usage for unsupported systems
If we select "unconfined" as AppArmor profile, then we should not error
even if the host does not support it at all. This behavior has been
fixed and a corresponding e2e test has been added as well.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-09-07 10:47:32 +02:00
Daniel J Walsh 3848cac860
In podman 1.* regression on --cap-add
In podman 1.0 if  you executed a command like:

podman run --user dwalsh --cap-add net_bind_service alpine nc -l 80

It would work, and the user dwalsh would get the capability,  in
podman 2.0, only root and the binding set gets the capability.

This change restores us back to the way podman 1.0 worked.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-08-21 10:56:29 -04:00
Sascha Grunert 97a2c86aab
Allow specifying seccomp profiles for privileged containers
To sync the behavior between AppArmor and seccomp it is now possible to
also specify seccomp profiles for privileged containers.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-08-11 11:18:52 +02:00
Daniel J Walsh a5e37ad280
Switch all references to github.com/containers/libpod -> podman
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-28 08:23:45 -04:00
Daniel J Walsh 4c4a00f63e
Support default profile for apparmor
Currently you can not apply an ApparmorProfile if you specify
--privileged.  This patch will allow both to be specified
simultaniosly.

By default Apparmor should be disabled if the user
specifies --privileged, but if the user specifies --security apparmor:PROFILE,
with --privileged, we should do both.

Added e2e run_apparmor_test.go

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-22 06:27:20 -04:00
Valentin Rothberg 8489dc4345 move go module to v2
With the advent of Podman 2.0.0 we crossed the magical barrier of go
modules.  While we were able to continue importing all packages inside
of the project, the project could not be vendored anymore from the
outside.

Move the go module to new major version and change all imports to
`github.com/containers/libpod/v2`.  The renaming of the imports
was done via `gomove` [1].

[1] https://github.com/KSubedi/gomove

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-07-06 15:50:12 +02:00
Daniel J Walsh fe69aa9ba3
Handle dropping capabilties correctly when running as non root user
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-17 17:20:53 -04:00
Daniel J Walsh 4a2765c498
Properly handle default capabilities listed in containers.conf
If user/admin specifies a different list of default capabilties
we need to honor these.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-01 15:00:26 -04:00
Daniel J Walsh eb101936e6
Handle Linux Capabilities correctly
If user sets capabilities list we need handle minimal capabilities.

Also handle seccomp-policy being passed in.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-20 15:50:46 -04:00
Brent Baude ba430bfe5e podman v2 remove bloat v2
rid ourseleves of libpod references in v2 client

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-16 12:04:46 -05:00