425 Commits

Author SHA1 Message Date
7b3cac1aa8 Apply required golang 1.17+ meta changes
Signed-off-by: Chris Evich <cevich@redhat.com>
2024-04-11 10:53:28 -04:00
e7a73108b3 Add container GID to additional groups
Mitigates a potential permissions issue. Mirrors Buildah PR #4200
and CRI-O PR #6159.

Signed-off-by: Matthew Heon <mheon@redhat.com>

MH: Backported to v4.0-rhel per RHBZ #2121541

Signed-off-by: Matthew Heon <mheon@redhat.com>
2023-02-03 13:32:06 -05:00
c919f0b884 do not set the inheritable capabilities
The kernel never sets the inheritable capabilities for a process, they
are only set by userspace.  Emulate the same behavior.

Closes: CVE-2022-27649

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
(cherry picked from commit aafa80918a245edcbdaceb1191d749570f1872d0)
2022-03-29 17:44:50 +02:00
9237d7500a [v4.0] Backport Set default rule at the head of dev config
Backports: #13421 Set default rule at the head of device configuration
by @hshiina

The default rule should be set at the head of device configuration.
Otherwise, rules for user devices are overridden by the default rule so
that any access to the user devices are denied.

This has been requested to backport and to include in RHEL 8.6 and 9.0.
The exception process is underway.

Addresses these BZs for the backport:

https://bugzilla.redhat.com/show_bug.cgi?id=2059296
https://bugzilla.redhat.com/show_bug.cgi?id=2062835

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
(cherry picked from commit 61f6e1300a770af58c43dd226ad6ebe68c5d1921)
Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2022-03-15 08:29:31 -04:00
eb9fe52a55 kube: honor mount propagation mode
convert the propagation mode specified for the mount to the expected
Linux mount option.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-02-23 14:26:10 -05:00
b1bf91a22a Podman pod create --share-parent vs --share=cgroup
separated cgroupNS sharing from setting the pod as the cgroup parent,
made a new flag --share-parent which sets the pod as the cgroup parent for all
containers entering the pod

remove cgroup from the default kernel namespaces since we want the same default behavior as before which is just the cgroup parent.

resolves #12765

Signed-off-by: cdoern <cdoern@redhat.com>
Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
Signed-off-by: cdoern <cdoern@redhat.com>
2022-02-10 13:49:46 -05:00
178cccbf9e Fix use of infra image to clarify default
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-02-03 14:45:29 -05:00
6336e1ff1e rootless: drop permission check for devices
commit 350ede1eeb6ab33bce2918d7768b940c255e63c6 added the feature.

Do not check whether the device is usable by the rootless user before
adding to the container.

Closes: https://github.com/containers/podman/issues/12704

[NO NEW TESTS NEEDED] it requires changes on the host to test it

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-27 09:35:02 +01:00
98739237ee pkg/specgen/generate/security: fix error message
This should be Network Namespace, not Host Namespace.

[NO NEW TESTS NEEDED]

Fixes: 0d70df11
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-01-24 13:24:37 -08:00
d847ad598d Merge pull request #12961 from rhatdan/codespell
Run codespell
2022-01-21 14:55:26 -05:00
6e17158502 Merge pull request #12948 from Luap99/rootless-networking
Remove rootless_networking option from containers.conf
2022-01-21 09:57:26 -05:00
5736649eb8 Run codespell on code
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-01-21 09:52:12 -05:00
9d815707e2 Fix nil pointer dereference for configmap optional
This PR fixes nil pointer dereference for configmap optional parameter.
When optional parameter is not passed, the code tried to acces the
parameter which caused nil pointer dereference.

Signed-off-by: Ondra Machacek <omachace@redhat.com>
2022-01-21 10:01:32 +01:00
ee039b7403 Remove rootless_networking option from containers.conf
This field was only needed for machine to force cni, however you can set
netns="bridge" in the config to have the same effect. This is already
done in the machine setup.

see https://github.com/containers/common/pull/895

[NO NEW TESTS NEEDED]

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-20 19:08:15 +01:00
bd09b7aa79 bump go module to version 4
Automated for .go files via gomove [1]:
`gomove github.com/containers/podman/v3 github.com/containers/podman/v4`

Remaining files via vgrep [2]:
`vgrep github.com/containers/podman/v3`

[1] https://github.com/KSubedi/gomove
[2] https://github.com/vrothberg/vgrep

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2022-01-18 12:47:07 +01:00
607cb80bf7 Fix cgroup mode handling in api server
Also change code to globably be consistent when refering to capatilized
Cgroup.

Fixed: https://github.com/containers/podman/issues/12550

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-01-14 12:32:35 -05:00
a15dfb3648 Standardize on capatalized Cgroups
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-01-14 12:30:20 -05:00
7ab99227e6 Merge pull request #12825 from elezar/update-cdi
Update use of CDI API
2022-01-14 15:17:21 +01:00
968deb7c2c Use new CDI API
This change updates the CDI API to commit 46367ec063fda9da931d050b308ccd768e824364
which addresses some inconistencies in the previous implementation.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
2022-01-14 13:35:22 +01:00
482e0b11d9 Merge pull request #12849 from cdoern/podProhibit
Prohibit --uid/gid map and --pod for container create/run
2022-01-14 13:08:17 +01:00
6996830104 Prohibit --uid/gid map and --pod for container create/run
add a check in namespaceOptions() that ensures the user is not setting a new uid/gid map
if entering or creating a pod that has an infra container

resolves #12669

Signed-off-by: cdoern <cdoern@redhat.com>
2022-01-13 14:03:51 -05:00
eeb76db0fd Merge pull request #12642 from Luap99/libnetwork
use libnetwork from c/common
2022-01-13 18:06:54 +01:00
ab7228b3c2 Merge pull request #12836 from cdoern/podSysCtl
Podman Pod Create --sysctl support
2022-01-13 16:44:52 +01:00
f257d98394 Podman Pod Create --sysctl support
added support for pod wide sysctls. The sysctls supported are the same as the continer run controls.

These controls are only valid if the proper namespaces are shared within the pod, otherwise only the infra ctr gets the sysctl

resolves #12747

Signed-off-by: cdoern <cdoern@redhat.com>
2022-01-12 20:49:04 -05:00
495884b319 use libnetwork from c/common
The libpod/network packages were moved to c/common so that buildah can
use it as well. To prevent duplication use it in podman as well and
remove it from here.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-12 17:07:30 +01:00
8f2358eeaa Add podman rm --depend
This option causes Podman to not only remove the specified containers
but all of the containers that depend on the specified
containers.
Fixes: https://github.com/containers/podman/issues/10360

Also ran codespell on the code

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-01-11 14:33:54 -05:00
a95c01e0e4 pkg: use PROXY_VARS from c/common
Signed-off-by: Aditya Rajan <arajan@redhat.com>
2022-01-11 00:46:10 +05:30
4dc5a5b15d Don't add env if optional and not found
If the pod yaml has env from secret and condifg map but they are optional
and the secret cannot be found, don't add the env key as well
as the env value will not be found. Matches behavior with k8s.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2022-01-10 05:51:19 -05:00
2a524fcaec fix healthcheck timeouts and ut8 coercion
this commit fixes two bugs and adds regression tests.

when getting healthcheck values from an image, if the image does not
have a timeout defined, this resulted in a 0 value for timeout.  The
default as described in the man pages is 30s.

when inspecting a container with a healthcheck command, a customer
observed that the &, <, and > characters were being converted into a
unicode escape value.  It turns out json marshalling will by default
coerce string values to ut8.

Fixes: bz2028408

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-01-06 13:56:54 -06:00
289270375a Pod Security Option support
Added support for pod security options. These are applied to infra and passed down to the
containers as added (unless overridden).

Modified the inheritance process from infra, creating a new function Inherit() which reads the config, and marshals the compatible options into an intermediate struct `InfraInherit`
This is then unmarshaled into a container config and all of this is added to the CtrCreateOptions. Removes the need (mostly) for special additons which complicate the Container_create
code and pod creation.

resolves #12173

Signed-off-by: cdoern <cdoern@redhat.com>
2021-12-27 13:39:36 -05:00
73a54ea54d Merge pull request #12627 from rhatdan/passwd
Allow users to add host user accounts to /etc/passwd
2021-12-23 19:28:08 +01:00
e8c06fac97 Allow users to add host user accounts to /etc/passwd
Some containers require certain user account(s) to exist within the
container when they are run. This option will allow callers to add a
bunch of passwd entries from the host to the container even if the
entries are not in the local /etc/passwd file on the host.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1935831

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-12-23 07:51:27 -05:00
1aa4e4d4d1 container creation: don't apply reserved annotations from image
Do not apply reserved annotations from the image to the container.
Reserved annotations are applied during container creation to retrieve
certain information (e.g., custom seccomp profile or autoremoval)
once a container has been created.

Context: #12671
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-12-23 13:40:46 +01:00
a5e49d9668 Warn on use of --kernel-memory
It has been deprecated and is no longer supported.  Fully remove it and
only print a warning if a user uses it.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2011695

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-12-22 06:20:21 -05:00
85f21fb2bd Merge pull request #12664 from cdoern/noManagePasswd
Podman run --passwd
2021-12-22 12:09:56 +01:00
20ce6e5c60 Podman run --passwd
added support for a new flag --passwd which, when false prohibits podman from creating entries in
/etc/passwd and /etc/groups allowing users to modify those files in the container entrypoint

resolves #11805

Signed-off-by: cdoern <cdoern@redhat.com>
2021-12-21 17:19:41 -05:00
89ee302a9f specgen: honor userns=auto from containers.conf
when using the default userns value, make sure its value is parsed so
that userns=auto is parsed and the options for the storage are filled.

Closes: https://github.com/containers/podman/issues/12615

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-20 17:03:40 +01:00
4243ca93a4 oci: configure the devices cgroup with default devices
always set the default devices to the devices cgroup when not running
in a user namespace.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-16 13:25:43 +01:00
ef325bc8c4 specgen: check that networks are only set with bridge
Because we cannot reqad the networking mode in the frontent because we
should always use the server default we have to parse the mac and ip
address to the server via a default network. Now when the server reads
the default nsmode it has to reject the provided networks when the mode
is not set to bridge.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-12-14 15:23:40 +01:00
535818414c support advanced network configuration via cli
Rework the --network parse logic to support multiple networks with
specific network configuration settings.
--network can now be set multiple times. For bridge network mode the
following options have been added:
  - **alias=name**: Add network-scoped alias for the container.
  - **ip=IPv4**: Specify a static ipv4 address for this container.
  - **ip=IPv6**: Specify a static ipv6 address for this container.
  - **mac=MAC**: Specify a static mac address address for this container.
  - **interface_name**: Specify a name for the created network interface inside the container.

So now you can set --network bridge:ip=10.88.0.10,mac=44:33:22:11:00:99
for the default bridge network as well as for network names.
This is better than using --ip because we can set the ip per network
without any confusion which network the ip address should be assigned
to.
The --ip, --mac-address and --network-alias options are still supported
but --ip or --mac-address can only be set when only one network is set.
This limitation already existed previously.

The ability to specify a custom network interface name is new
Fixes #11534

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-12-14 15:23:39 +01:00
d072167fe2 Add new networks format to spegecen
Add the new networks format to specgen. For api users cni_networks is
still supported to make migration easier however the static ip and mac
fields are removed.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-12-14 15:23:39 +01:00
9ce6b64133 network db: add new strucutre to container create
Make sure we create new containers in the db with the correct structure.
Also remove some unneeded code for alias handling. We no longer need this
functions.

The specgen format has not been changed for now.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-12-14 15:23:39 +01:00
593d0907c5 --hostname should be set when using --pod new:foobar
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2030599

When you create pod, it shares the UTS namespace with Containers.
Currently the --hostname is not passed to the pod created when
you create a container and pod in the same command.

Also fix error message on supported --share flags

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-12-09 13:09:02 -05:00
2130d18539 Update vendor or containers/common moving pkg/cgroups there
[NO NEW TESTS NEEDED] This is just moving pkg/cgroups out so
existing tests should be fine.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-12-07 06:17:11 -05:00
dd109daa45 Merge pull request #12440 from umohnani8/cm
Add support for configmap volumes to play kube
2021-12-03 14:54:47 +01:00
7d331d35dd Add support for configmap volumes to play kube
If the k8s yaml has volumes from a configmap, play kube
will now create a volume based on the data from the
configmap and volume source and set it to the right path
in the container accordingly.
Add tests for this and update some test for ENV from configmap.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2021-12-02 14:48:04 -05:00
5a56f40948 Implement 'podman run --blkio-weight-device'
`--blkio-weight-device` is not fully implemented and this causes an
unexpected panic when specified because an entry is put into an
uninitialized map at parsing.

This fix implements the `--blkio-weight-device` and adds a system test.
When creating a spec generator on a client, a major number and a minor
number of a device cannot be set. So, these numbers are inspected on a
server and set to a runtime spec.

Signed-off-by: Hironori Shiina <shiina.hironori@jp.fujitsu.com>
2021-11-30 09:21:28 -05:00
02be831ce7 Support EXPOSE with port ranges
Fixes issue #12293. EXPOSE directive in images should mirror the --expose
parameter. Specifically `EXPOSE 20000-20100/tcp` should work the same
as `--expose 20000-20100/tcp`

Signed-off-by: Colin Bendell <colin@bendell.ca>
2021-11-20 19:24:21 -05:00
0dae50f1d3 Do not store the exit command in container config
There is a problem with creating and storing the exit command when the
container was created. It only contains the options the container was
created with but NOT the options the container is started with. One
example would be a CNI network config. If I start a container once, then
change the cni config dir with `--cni-config-dir` ans start it a second
time it will start successfully. However the exit command still contains
the wrong `--cni-config-dir` because it was not updated.

To fix this we do not want to store the exit command at all. Instead we
create it every time the conmon process for the container is startet.
This guarantees us that the container cleanup process is startet with
the correct settings.

[NO NEW TESTS NEEDED]

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-11-18 20:28:03 +01:00
197ebe8b5e Merge pull request #12218 from vrothberg/pause-catatonit
infra container: replace pause with catatonit
2021-11-16 18:16:34 +01:00