3118 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
febde1a23f [v4.0-rhel] container: do not create .containerenv with -v SRC:/run
if /run is on a volume do not create the file /run/.containerenv as it
would leak outside of the container.

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

Backporting #14582 to v4.0-rhel to complete the backports to https://issues.redhat.com/browse/OCPBUGS-7522

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Tom Sweeney <tsweeney@redhat.com>
2023-05-25 15:55:03 -04:00
a5d8acb304 volume,container: chroot to source before exporting content
* Utils must support higher level API to create Tar with chrooted into
  directory
* Volume export: use TarwithChroot instead of Tar so we can make sure no
  symlink can be exported by tar if it exists outside of the source
directory.
* container export: use chroot and Tar instead of Tar so we can make sure no
  symlink can be exported by tar if it exists outside of the mointPoint.

[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]
Race needs combination of external/in-container mechanism which is hard to repro in CI.

Closes: BZ:#2168256
CVE: https://access.redhat.com/security/cve/CVE-2023-0778

Signed-off-by: Aditya R <arajan@redhat.com>

MH: Backport to v4.4-rhel per RHBZ 2169617

Signed-off-by: Matt Heon <mheon@redhat.com>
2023-02-16 11:41:27 -05: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
361ec22fe5 [v4.0-rhel] all: stop using deprecated GenerateNonCryptoID
Cherry-pick #15788 to v4.0-rhel branch per RHBZ 2157930

In view of https://github.com/containers/storage/pull/1337, do this:

	for f in $(git grep -l stringid.GenerateNonCryptoID | grep -v '^vendor/'); do
		sed -i 's/stringid.GenerateNonCryptoID/stringid.GenerateRandomID/g' $f;
	done

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2023-02-01 17:45:36 -05:00
e9cf473549 runtime: unpause the container before killing it
the new version of runc has the same check in place and it
automatically resume the container if it is paused.  So when Podman
tries to resume it again, it fails since the container is not in the
paused state.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2100740

[NO NEW TESTS NEEDED] the CI doesn't use a new runc on cgroup v1 systems.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-01-24 12:34:33 -07:00
cb036e5ef7 libpod/networking_linux.go: switch to sha256 hashes
SHA-1 is prone to collisions.

This will likely break connectivity between old containers started
before update and containers started after update. It will also fail to
cleanup old netns. A reboot will fix this, so a reboot is recommended
after update.

[NO NEW TESTS NEEDED]

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
(cherry picked from commit 44642bee8720c0a19c97c6e116d725fd5f95daad)
Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2022-04-26 14:33:23 -04: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
02f1647753 slirp: fix setup on ipv6 disabled systems
When enable_ipv6=true is set for slirp4netns (default since podman v4),
we will try to set the accept sysctl. This sysctl will not exist on
systems that have ipv6 disabled. In this case we should not error and
just ignore the extra ipv6 setup.

Also the current logic to wait for the slirp4 setup was kinda broken, it
did not actually wait until the sysctl was set before starting slirp.
This should now be fixed by using two `sync.WaitGroup`s.

[NO NEW TESTS NEEDED]

Fixes #13388

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-03-18 14:28:54 +00:00
697dd2890e Propagate $CONTAINERS_CONF to conmon
The CONTAINERS_CONF environment variable can be used to override the
configuration file, which is useful for testing.  However, at the moment
this variable is not propagated to conmon.  That means in particular, that
conmon can't propagate it back to podman when invoking its --exit-command.
The mismatch in configuration between the starting and cleaning up podman
instances can cause a variety of errors.

This patch also adds two related test cases.  One checks explicitly that
the correct CONTAINERS_CONF value appears in conmon's environment.  The
other checks for a possible specific impact of this bug: if we use a
nonstandard name for the runtime (even if its path is just a regular crun),
then the podman container cleanup invoked at container exit will fail.
That has the effect of meaning that a container started with -d --rm won't
be correctly removed once complete.

Fixes #12917

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2022-02-23 14:33:07 -05:00
71b0909f2d Remove the runtime lock
This primarily served to protect us against shutting down the
Libpod runtime while operations (like creating a container) were
happening. However, it was very inconsistently implemented (a lot
of our longer-lived functions, like pulling images, just didn't
implement it at all...) and I'm not sure how much we really care
about this very-specific error case?

Removing it also removes a lot of potential deadlocks, which is
nice.

[NO NEW TESTS NEEDED]

Signed-off-by: Matthew Heon <mheon@redhat.com>
2022-02-23 14:29:41 -05:00
ee7cf3cc2c Don't log errors on removing volumes inuse, if container --volumes-from
When removing a container created with a --volumes-from a container
created with a built in volume, we complain if the original container
still exists.  Since this is an expected state, we should not complain
about it.

Fixes: https://github.com/containers/podman/issues/12808

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-02-23 14:27:52 -05:00
d77b4f92c0 Fix checkpoint/restore pod tests
Checkpoint/restore pod tests are not running with an older runc and now
that runc 1.1.0 appears in the repositories it was detected that the
tests were failing. This was not detected in CI as CI was not using runc
1.1.0 yet.

Signed-off-by: Adrian Reber <areber@redhat.com>
2022-02-16 13:58:40 -05:00
77ca2498e9 Modify /etc/resolv.conf when connecting/disconnecting
The `podman network connect` and `podman network disconnect`
commands give containers access to different networks than the
ones they were created with; these networks can also have DNS
servers associated with them. Until now, however, we did not
modify resolv.conf as network membership changed.

With this PR, `podman network connect` will add any new
nameservers supported by the new network to the container's
/etc/resolv.conf, and `podman network disconnect` command will do
the opposite, removing the network's nameservers from
`/etc/resolv.conf`.

Fixes #9603

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2022-02-10 14:05:48 -05:00
6d01b6dd63 fix: Multiplication of durations
'killContainerTimeout' is already 5 second
[NO NEW TESTS NEEDED]

Signed-off-by: myml <wurongjie1@gmail.com>
2022-02-10 14:01:42 -05:00
ed60f89086 move rootless netns slirp4netns process to systemd user.slice
When running podman inside systemd user units, it is possible that
systemd kills the rootless netns slirp4netns process because it was
started in the default unit cgroup. When the unit is stopped all
processes in that cgroup are killed. Since the slirp4netns process is
run once for all containers it should not be killed. To make sure
systemd will not kill the process we move it to the user.slice.

Fixes #13153

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-02-10 13:59:07 -05:00
74cba33c78 healthcheck, libpod: Read healthcheck event output from os pipe
It seems we are ignoring output from healthcheck session.
Open a valid pipe to healthcheck session in order read its output.

Use common pipe for both `stdout/stderr` since that was the previous
behviour as well.

Signed-off-by: Aditya R <arajan@redhat.com>
2022-02-10 13:56:22 -05:00
7ec63f092f Fix: Do not print error when parsing journald log fails
foramtError was written as err
[NO NEW TESTS NEEDED]

Signed-off-by: myml <wurongjie1@gmail.com>
2022-02-10 13:55:24 -05:00
bcd5f5ead7 append podman dns search domain
Append the podman dns seach domain to the host search domains when we
use the dnsname/aardvark server. Previously it would only use podman
seach domains and discard the host domains.

Fixes #13103

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-02-10 13:54:18 -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
e0cbcdc335 system prune: remove all networks
podman system prune should also remove all networks. When we want to
users to migrate to the new network stack we recommend to run podman
system reset. However this did not remove networks and if there were
still networks around we would continue to use cni since this was
considered an old system.

There is one exception for the default network. It should not be removed
since this could cause other issues when it no longer exists. The
network backend detection logic ignores the default network so this is
fine.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-02-03 15:01:29 -05:00
06821627fb libpod: enforce noexec,nosuid,nodev for /dev/shm
these mount flags are already used for the /dev/shm mount on the host,
but they are not set for the bind mount itself.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-02-03 14:50:04 -05:00
9d3bcb5875 libpod: report slirp4netns network stats
by default slirp4netns uses the tap0 device.  When slirp4netns is
used, use that device by default instead of eth0.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-02-03 14:46:01 -05:00
e64e6500d3 volume: add support for non-volatile upperdir,workdir for overlay volumes
Often users want their overlayed volumes to be `non-volatile` in nature
that means that same `upper` dir can be re-used by one or more
containers but overall of nature of volumes still have to be `overlay`
so work done is still on a overlay not on the actual volume.

Following PR adds support for more advanced options i.e custom `workdir`
and `upperdir` for overlayed volumes. So that users can re-use `workdir`
and `upperdir` across new containers as well.

Usage
```console

$ podman run -it -v myvol:/data:O,upperdir=/path/persistant/upper,workdir=/path/persistant/work alpine sh

```

Signed-off-by: Aditya R <arajan@redhat.com>
2022-01-28 13:10:15 +05:30
92635c726a Merge pull request #12857 from giuseppe/fix-rm-dir-not-empty
exec: retry rm -rf on ENOTEMPTY and EBUSY
2022-01-25 10:09:43 -05:00
e252b3b4f2 exec: retry rm -rf on ENOTEMPTY and EBUSY
when running on NFS, a RemoveAll could cause EBUSY because of some
unlinked files that are still kept open and "silly renamed" to
.nfs$ID.

This is only half of the fix, as conmon needs to be fixed too.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2040379
Related: https://github.com/containers/conmon/pull/319

[NO NEW TESTS NEEDED] as it requires NFS as the underlying storage.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-24 16:58:05 +01:00
2f371cb12c container create: do not check for network dns support
We should not check if the network supports dns when we create a
container with network aliases. This could be the case for containers
created by docker-compose for example if the dnsname plugin is not
installed or the user uses a macvlan config where we do not support dns.

Fixes #12972

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-24 16:56:11 +01:00
75e6994d4e libpod: fix leaking fd
the config.json file for the OCI runtime is never closed, this is a
problem when running on NFS, since it leaves around stale files that
cannot be unlinked.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-24 16:05:46 +01:00
f6e36a6497 libpod: fix connection leak
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-24 16:05:42 +01:00
5736649eb8 Run codespell on code
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-01-21 09:52:12 -05:00
dbaaef5c4c Show package version when running on alpine
Tested manually.

[NO NEW TESTS NEEDED]

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
2022-01-19 18:55:03 +01:00
7e30531f20 compat attach: fix write on closed channel
Waiting on an initialized sync.WaitGroup returns immediately.
Hence, move the goroutine to wait and close *after* reading
the logs.

Fixes: #12904
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2022-01-18 16:32:38 +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
d6b0720b9c Merge pull request #12684 from mheon/remap_states
Revamp Libpod state strings for Docker compat
2022-01-18 06:22:05 -05:00
d0eb24bae0 Merge pull request #12870 from rhatdan/userns1
Use PODMAN_USERNS environment variable when running as a service
2022-01-18 06:08:06 -05:00
141de86862 Revamp Libpod state strings for Docker compat
Improve our compatibility with Docker by better handling the
state strings that we print in `podman ps`. Docker capitalizes
all states in `ps` (we do not) - fix this in our PS code. Also,
stop normalizing ContainerStateConfigured to the "Created" state,
and instead make it always be Created, with the existing Created
state becoming Initialized.

I didn't rename the actual states because I'm somewhat reticent
to make such a large change a day before we leave for break. It's
somewhat confusing that ContainerStateConfigured now returns
Created, but internally and externally we're still consistent.

[NO NEW TESTS NEEDED] existing tests should catch anything that
broke.

I also consider this a breaking change. I will flag appropriately
on Github.

Fixes RHBZ#2010432 and RHBZ#2032561

Signed-off-by: Matthew Heon <mheon@redhat.com>
2022-01-17 13:56:07 -05:00
10d969ff1a Use PODMAN_USERNS environment variable when running as a service
Fixes: https://github.com/containers/podman/issues/11350#issuecomment-1011562526

Also add inspect information about the idmappings if they exists.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-01-17 06:48:54 -05:00
a15dfb3648 Standardize on capatalized Cgroups
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-01-14 12:30:20 -05: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
2c510146aa Merge pull request #12828 from giuseppe/drop-check
libpod: drop check for empty pod cgroup
2022-01-13 20:25:09 +01:00
48e63975aa Merge pull request #12826 from vrothberg/force-rm-pod
podman container rm: remove pod
2022-01-13 18:40:52 +01:00
eeb76db0fd Merge pull request #12642 from Luap99/libnetwork
use libnetwork from c/common
2022-01-13 18:06:54 +01:00
a4cef54350 podman container rm: remove pod
Support removing the entire pod when --depend is used on an infra
container.  --all now implies --depend to properly support removing all
containers and not error out when hitting infra containers.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2022-01-13 17:08:31 +01:00
fa6405c3c3 use events_logfile_path from containers.conf for events log.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-01-13 08:14:50 -05:00
194d14ca2f libpod: fix check for systemd session
move the check after the cgroup manager is set, so to correctly detect
--cgroup-manager=cgroupfs and do not raise a warning about dbus not
being present.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-12 21:18:15 +01:00
8dc2464b03 libpod: refine check for empty pod cgroup
rootless containers do not use cgroups on cgroupv1 or if using
cgroupfs, so improve the check to account for such configuration.

Closes: https://github.com/containers/podman/issues/10800
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2028243

[NO NEW TESTS NEEDED] it requires rebooting and the rundir on a non
tmpfs file system.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-12 21:07:24 +01:00
918890a4d6 use netns package from c/common
The netns package was moved to c/common so we should use this and remove
the package from podman.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-12 17:40:24 +01:00
0151e10b62 update buildah to latest and use new network stack
Make sure buildah uses the new network stack.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-12 17:40:12 +01: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
83b0fb4696 Fix permission on secrets directory
This directory needs to be world searchable so users can access it from
different user namespaces.

Fixes: https://github.com/containers/podman/issues/12779

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-01-11 16:19:50 -05:00