spiegel_podman/libpod
Paul Holzinger 9078ca3b69
libpod: bind ports before network setup
We bind ports to ensure there are no conflicts and we leak them into
conmon to keep them open. However we bound the ports after the network
was set up so it was possible for a second network setup to overwrite
the firewall configs of a previous container as it failed only later
when binding the port. As such we must ensure we bind before the network
is set up.

This is not so simple because we still have to take care of
PostConfigureNetNS bool in which case the network set up happens after
we launch conmon. Thus we end up with two different conditions.

Also it is possible that we "leak" the ports that are set on the
container until the garbage collector will close them. This is not
perfect but the alternative is adding special error handling on each
function exit after prepare until we start conmon which is a lot of work
to do correctly.

Fixes https://issues.redhat.com/browse/RHEL-50746

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
(cherry picked from commit 77081df8cd)
Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
2026-02-04 17:23:27 +05:30
..
define [v4.4-rhel] Adjust for common bump 2025-12-17 15:40:01 -05:00
driver bump go module to version 4 2022-01-18 12:47:07 +01:00
events journald: podman events only show events for current user 2023-01-27 19:27:02 +00:00
layers Initial checkin from CRI-O repo 2017-11-01 11:24:59 -04:00
linkmode go fmt: use go 1.18 conditional-build syntax 2022-03-18 09:11:53 +01:00
lock Update c/storage after https://github.com/containers/storage/pull/1436 2022-12-01 16:05:13 +01:00
logs bump golangci-lint to v1.50.1 2022-12-15 13:39:56 +01:00
plugin bump golangci-lint to v1.49.0 2022-10-17 09:19:41 +02:00
shutdown libpod: switch to golang native error wrapping 2022-07-05 16:06:32 +02:00
boltdb_state.go DB: make loading container states optional 2023-01-27 09:14:12 +00:00
boltdb_state_internal.go DB: make loading container states optional 2023-01-27 09:14:12 +00:00
boltdb_state_unsupported.go libpod: Add definition of containerPlatformState for FreeBSD 2022-08-23 15:31:00 +01:00
common_test.go bump go module to version 4 2022-01-18 12:47:07 +01:00
container.go libpod: bind ports before network setup 2026-02-04 17:23:27 +05:30
container_api.go ps: do not sync container 2023-01-27 09:14:12 +00:00
container_commit.go commit: use libimage code to parse changes 2023-01-16 16:28:11 +01:00
container_config.go libpod: remove CNI word were no longer applicable 2022-12-16 14:20:14 +01:00
container_copy_common.go libpod: Implement 'podman cp' for FreeBSD 2022-09-20 08:36:23 +01:00
container_copy_freebsd.go libpod: Implement 'podman cp' for FreeBSD 2022-09-20 08:36:23 +01:00
container_copy_linux.go libpod: Move jointMountAndExec to container_copy_linux.go 2022-09-20 08:36:23 +01:00
container_copy_unsupported.go libpod: Implement 'podman cp' for FreeBSD 2022-09-20 08:36:23 +01:00
container_exec.go Replace deprecated ioutil 2022-09-20 15:34:27 -04:00
container_freebsd.go libpod: move NetNS into state db instead of extra bucket 2022-12-16 18:30:12 +01:00
container_graph.go Introduce graph-based pod container removal 2022-09-14 13:44:48 -04:00
container_graph_test.go bump go module to version 4 2022-01-18 12:47:07 +01:00
container_inspect.go Add container error message to ContainerState 2023-01-03 13:21:24 -05:00
container_inspect_freebsd.go libpod: Factor out platform-specfic code from generateInspectContainerHostConfig 2022-09-15 08:10:34 +01:00
container_inspect_linux.go [v4.4-rhel] Adjust for common bump 2025-12-17 15:40:01 -05:00
container_internal.go Ignore SELinux relabel on unsupported file systems 2026-01-29 18:41:50 +05:30
container_internal_common.go Add missing unix import for ENOTSUP 2026-01-29 18:41:50 +05:30
container_internal_freebsd.go libpod: bind ports before network setup 2026-02-04 17:23:27 +05:30
container_internal_linux.go libpod: bind ports before network setup 2026-02-04 17:23:27 +05:30
container_internal_linux_test.go test: use T.TempDir to create temporary test directory 2022-05-05 21:09:41 +08:00
container_internal_test.go [v4.4.1-rhel] Vendor c/storage v1.45.5 2023-04-13 08:44:36 -04:00
container_internal_unsupported.go libpod: Add FreeBSD implementation of container internals 2022-09-05 10:12:12 +01:00
container_linux.go libpod: move NetNS into state db instead of extra bucket 2022-12-16 18:30:12 +01:00
container_log.go k8s-file: podman logs --until --follow exit after time 2023-01-06 15:19:23 +01:00
container_log_linux.go journald: podman logs only show logs for current user 2023-01-27 19:27:02 +00:00
container_log_unsupported.go libpod: switch to golang native error wrapping 2022-07-05 16:06:32 +02:00
container_path_resolution.go bump golangci-lint to v1.49.0 2022-10-17 09:19:41 +02:00
container_path_resolution_test.go libpod: fix lookup for subpath in volumes 2022-09-14 17:09:04 +02:00
container_stat_common.go libpod: Implement 'podman cp' for FreeBSD 2022-09-20 08:36:23 +01:00
container_stat_freebsd.go libpod: Implement 'podman cp' for FreeBSD 2022-09-20 08:36:23 +01:00
container_stat_linux.go libpod: Move part of (*Container).stat to container_stat_linux.go 2022-09-20 08:36:23 +01:00
container_stat_unsupported.go libpod: Implement 'podman cp' for FreeBSD 2022-09-20 08:36:23 +01:00
container_top_freebsd.go libpod: Add support for 'podman top' on FreeBSD 2022-10-17 16:43:53 +01:00
container_top_linux.go Fix stutters 2022-09-10 07:52:00 -04:00
container_top_unsupported.go libpod: Add support for 'podman top' on FreeBSD 2022-10-17 16:43:53 +01:00
container_unsupported.go libpod: Add definition of containerPlatformState for FreeBSD 2022-08-23 15:31:00 +01:00
container_validate.go libpod: remove CNI word were no longer applicable 2022-12-16 14:20:14 +01:00
diff.go libpod: switch to golang native error wrapping 2022-07-05 16:06:32 +02:00
doc.go document that using libpod package directly is not supported 2022-03-23 19:05:29 +01:00
events.go container create: add inspect data to event 2022-11-29 10:40:24 +01:00
healthcheck.go [v4.4.1-rhel] fix --health-on-failure=restart in transient unit 2023-03-21 09:18:42 +01:00
healthcheck_linux.go health check: ignore dependencies of transient systemd units/timers 2022-12-08 15:01:57 +01:00
healthcheck_nosystemd_linux.go disable healthchecks automatically on non systemd systems 2022-12-05 20:58:30 +01:00
healthcheck_unsupported.go libpod: Track healthcheck API changes in healthcheck_unsupported.go 2022-12-02 16:41:21 +00:00
info.go runtime: Handle the transient store options 2022-12-05 18:09:21 +01:00
info_freebsd.go Fix stutters 2022-09-10 07:52:00 -04:00
info_linux.go [v4.4-rhel] Adjust for common bump 2025-12-17 15:40:01 -05:00
info_test.go libpod: Make unit test for statToPercent Linux only 2022-11-13 10:56:15 +00:00
info_unsupported.go libpod: Enable 'podman info' for FreeBSD 2022-08-24 10:55:52 +01:00
kube.go [v4.4-rhel] Adjust for common bump 2025-12-17 15:40:01 -05:00
mounts_linux.go go fmt: use go 1.18 conditional-build syntax 2022-03-18 09:11:53 +01:00
networking_common.go libpod: bind ports before network setup 2026-02-04 17:23:27 +05:30
networking_freebsd.go libpod: move NetNS into state db instead of extra bucket 2022-12-16 18:30:12 +01:00
networking_linux.go Ignore SELinux relabel on unsupported file systems 2026-01-29 18:41:50 +05:30
networking_linux_test.go enable unparam linter 2022-04-25 13:23:20 +02:00
networking_machine.go Replace deprecated ioutil 2022-09-20 15:34:27 -04:00
networking_pasta_linux.go libpod: move NetNS into state db instead of extra bucket 2022-12-16 18:30:12 +01:00
networking_slirp4netns.go [v4.4-rhel] Adjust for common bump 2025-12-17 15:40:01 -05:00
networking_unsupported.go libpod: remove CNI word were no longer applicable 2022-12-16 14:20:14 +01:00
oci.go bump golangci-lint to v1.49.0 2022-10-17 09:19:41 +02:00
oci_conmon.go podman: add new cgroup mode split 2020-06-25 17:16:12 +02:00
oci_conmon_attach_common.go [v4.4-rhel] Adjust for common bump 2025-12-17 15:40:01 -05:00
oci_conmon_attach_freebsd.go libpod: Build oci_conmon_common.go and oci_conmon_attach_common on FreeBSD 2022-08-18 08:07:30 +01:00
oci_conmon_attach_linux.go libpod: Move openUnixSocket to oci_conmon_attach_linux.go 2022-08-18 08:05:42 +01:00
oci_conmon_common.go libpod: bind ports before network setup 2026-02-04 17:23:27 +05:30
oci_conmon_exec_common.go [v4.4-rhel] Adjust for common bump 2025-12-17 15:40:01 -05:00
oci_conmon_exec_freebsd.go libpod: Factor out capabilites code from prepareProcessExec 2022-09-07 07:58:37 +01:00
oci_conmon_exec_linux.go libpod: Factor out capabilites code from prepareProcessExec 2022-09-07 07:58:37 +01:00
oci_conmon_freebsd.go libpod: Make sure writeConmonPipeData is called on FreeBSD 2022-08-29 13:04:04 +01:00
oci_conmon_linux.go [v4.4-rhel] replace deprecated selinux/label calls 2025-12-17 15:40:01 -05:00
oci_conmon_unsupported.go libpod: Build oci_conmon_common.go and oci_conmon_attach_common on FreeBSD 2022-08-18 08:07:30 +01:00
oci_missing.go implement podman update 2022-09-01 13:02:01 -04:00
oci_util.go libpod: bind ports before network setup 2026-02-04 17:23:27 +05:30
options.go [v4.4-rhel] Adjust for common bump 2025-12-17 15:40:01 -05:00
pod.go resource limits for pods 2022-07-21 14:50:01 -04:00
pod_api.go Merge pull request #16818 from SoMuchForSubtlety/api-port-bindings 2022-12-15 20:19:53 -05:00
pod_internal.go bump golangci-lint to v1.50.1 2022-12-15 13:39:56 +01:00
pod_internal_freebsd.go libpod: Factor out cgroups handling from (*Pod).refresh 2022-10-07 08:26:10 +01:00
pod_internal_linux.go libpod: Factor out cgroups handling from (*Pod).refresh 2022-10-07 08:26:10 +01:00
pod_status.go bump go module to version 4 2022-01-18 12:47:07 +01:00
pod_top_linux.go libpod/pod_top_linux.go: s/TODO/NOTE/ 2022-05-25 12:30:19 +02:00
pod_top_unsupported.go libpod: Add stubs for non-linux builds 2022-08-17 11:45:07 +01:00
reset.go Update c/storage after https://github.com/containers/storage/pull/1436 2022-12-01 16:05:13 +01:00
runtime.go Fix runtime initialization for missing StaticDir and VolumePath 2025-12-18 15:55:40 -05:00
runtime_cstorage.go Fix storage container mount check to fail on errors 2026-01-29 18:41:50 +05:30
runtime_ctr.go [v4.4.1-rhel] libpod: fix deadlock while parallel container create 2024-03-15 16:13:29 -04:00
runtime_ctr_freebsd.go libpod: Don't mount /dev/shm in containers on FreeBSD 2022-09-05 10:20:50 +01:00
runtime_ctr_linux.go libpod: Don't mount /dev/shm in containers on FreeBSD 2022-09-05 10:20:50 +01:00
runtime_img.go DB: make loading container states optional 2023-01-27 09:14:12 +00:00
runtime_migrate.go DB: make loading container states optional 2023-01-27 09:14:12 +00:00
runtime_migrate_unsupported.go libpod: Add stubs for non-linux builds 2022-08-17 11:45:07 +01:00
runtime_pod.go libpod/runtime: switch to golang native error wrapping 2022-07-04 15:39:00 +02:00
runtime_pod_common.go libpod: Add support for 'podman pod' on FreeBSD 2022-10-07 08:27:27 +01:00
runtime_pod_freebsd.go libpod: Add support for 'podman pod' on FreeBSD 2022-10-07 08:27:27 +01:00
runtime_pod_linux.go Fix updated runc dep breaking pod devices cgroup 2024-02-02 09:26:40 -05:00
runtime_pod_unsupported.go libpod: Add support for 'podman pod' on FreeBSD 2022-10-07 08:27:27 +01:00
runtime_renumber.go DB: make loading container states optional 2023-01-27 09:14:12 +00:00
runtime_test.go libpod: Ensure that generated container names are random 2022-09-01 10:27:04 +01:00
runtime_volume.go libpod/runtime: switch to golang native error wrapping 2022-07-04 15:39:00 +02:00
runtime_volume_common.go Fix several issues with image volumes 2023-06-12 13:31:39 -04:00
runtime_volume_unsupported.go libpod: Add volume support for FreeBSD 2022-09-27 16:31:40 +01:00
runtime_worker.go work queue: simplify and use a wait group 2022-05-25 10:17:46 +02:00
service.go service container: less verbose error logs 2023-01-12 14:09:23 +01:00
state.go DB: make loading container states optional 2023-01-27 09:14:12 +00:00
state_test.go DB: make loading container states optional 2023-01-27 09:14:12 +00:00
stats_common.go libpod: Split out the common code from GetContainerStats 2022-09-14 08:29:26 +01:00
stats_freebsd.go Fix swapped NetInput/-Output stats 2022-11-28 12:26:41 +01:00
stats_linux.go Fix swapped NetInput/-Output stats 2022-11-28 12:26:41 +01:00
stats_unsupported.go libpod: Add support for 'podman stats' on FreeBSD 2022-09-14 08:29:26 +01:00
storage.go Fix userns=auto failures in rootless mode 2026-01-14 19:28:30 +05:30
util.go Ignore SELinux relabel on unsupported file systems 2026-01-29 18:41:50 +05:30
util_freebsd.go libpod: Add support for 'podman pod' on FreeBSD 2022-10-07 08:27:27 +01:00
util_linux.go Ignore SELinux relabel on unsupported file systems 2026-01-29 18:41:50 +05:30
util_linux_test.go [v4.4-rhel] replace deprecated selinux/label calls 2025-12-17 15:40:01 -05:00
util_test.go bump go module to version 4 2022-01-18 12:47:07 +01:00
util_unsupported.go libpod: Add volume support for FreeBSD 2022-09-27 16:31:40 +01:00
volume.go Fix several issues with image volumes 2023-06-12 13:31:39 -04:00
volume_inspect.go Add support for 'image' volume driver 2022-09-22 13:07:40 -04:00
volume_internal.go Add support for 'image' volume driver 2022-09-22 13:07:40 -04:00
volume_internal_common.go libpod: Add volume support for FreeBSD 2022-09-27 16:31:40 +01:00
volume_internal_freebsd.go libpod: Add volume support for FreeBSD 2022-09-27 16:31:40 +01:00
volume_internal_linux.go libpod: Factor out usage of unix.MNT_DETACH from (*Volume).unmount 2022-09-27 16:31:40 +01:00
volume_internal_unsupported.go libpod: Add volume support for FreeBSD 2022-09-27 16:31:40 +01:00