Commit Graph

14 Commits

Author SHA1 Message Date
Paul Holzinger
aaadb4726d SetupRootless handle case where conmon pid are not valid
When trying to join the conmon pid to recreate the pause process based
on the namespace it can be that the pid is no longer valid, i.e. when
conmon crashed or was killed.

Currently we have a big issue that can be reproduced using:
$ podman run -d quay.io/libpod/testimage:20241011 sleep 100
$ killall -9 conmon
$ killall catatonit

All commands would fail as we keep trying to rejoin the namespace of the
non existing conmon process.

So to address that fall back to creating a new namespace if we fail to
join the conmon pids.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-11-25 19:52:24 +01:00
Paul Holzinger
4833357c72 preallocate paths in SetupRootless
Just a minor improvement as we know the size needed for the slice we can
allocate it only once instead of the append having to resize it.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-11-25 19:52:24 +01:00
Paul Holzinger
ed9d298fb4 fix noMoveProcess in SetupRootless
Based on the description in commit 63ef557 this was added so that the
migrate command does not move the pause process into a separate cgroup.

It should however not disable the rejoining of the userns when the pause
process join failed. BEcause of this we end up calling migrate without a
userns and that then can fail if there are actual contianer it tries to
cleanup.

Fixes: 63ef5576ed ("command: migrate doesn't move process to cgroup")

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-11-25 19:52:24 +01:00
Paul Holzinger
c3f3dd36c4 use return error handling in SetupRootless
There is no good reason to use logrus and os.Exit() here, other parts of
this function already return the error so do the same. The main podman
process will exit then with the normal formatted error message.

And also log an error about the last return which should never happen as
we should have exited above if the re-exec worked or errored out.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-11-25 19:51:48 +01:00
Matt Heon
34166fc004 Bump Go version to v6
Tremendous amount of changes in here, but all should amount to
the same thing: changing Go import paths from v5 to v6.

Also bumped go.mod to github.com/containers/podman/v6 and updated
version to v6.0.0-dev.

Signed-off-by: Matt Heon <mheon@redhat.com>
2025-10-23 11:00:15 -04:00
Jan Kaluza
a98154a978 Switch common, storage and image to monorepo.
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2025-09-01 12:33:04 +02:00
Paul Holzinger
942f789a88 set !remote build tags where needed
The new golangci-lint version 1.60.1 has problems with typecheck when
linting remote files. We have certain pakcages that should never be
inlcuded in remote but the typecheck tries to compile all of them but
this never works and it seems to ignore the exclude files we gave it.

To fix this the proper way is to mark all packages we only use locally
with !remote tags. This is a bit ugly but more correct. I also moved the
DecodeChanges() code around as it is called from the client so the
handles package which should only be remote doesn't really fit anyway.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-08-19 11:41:28 +02:00
Paul Holzinger
a2c83cb0fd SetupRootless(): only reexec when needed
We should never try to reexxec when we are already root with
CAP_SYS_ADMIN. The code contained a bug when --cgroups=disabled is used
as it tried to perfom a reexec even when it was not needed.

Fixes: 900e29549a ("libpod: do not move podman with --cgroups=disabled")

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-07-08 13:39:15 +02:00
Paul Holzinger
3350cd3eed pkg/rootless: simplify reexec for container code
The code currently tried to avoid joining the userns from conmon
directly and rather joined to only read the pid file and then send this
back to use so we could join the userns. From the comment this was done
because we could not read the pid file. However this is no longer true
as of commit 49eb5af301 and file is no always owned by the real user.

This means we can just remove this special logic and join the namespace
directly there. A test has been added to check the rejoin logic with a
custom uidmapping.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-07-08 13:28:31 +02:00
Giuseppe Scrivano
900e29549a libpod: do not move podman with --cgroups=disabled
The expectation with --cgroups=disabled is that the current cgroup is
used by the container.

Currently the --cgroups=disabled is passed directly to the OCI
runtime, but it doesn't stop Podman from creating a new cgroup when it
doesn't own the current one.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-05-30 16:59:30 +02:00
Matt Heon
72f1617fac Bump Go module to v5
Moving from Go module v4 to v5 prepares us for public releases.

Move done using gomove [1] as with the v3 and v4 moves.

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

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-02-08 09:35:39 -05:00
Giuseppe Scrivano
1322f3193b abi: drop check for IsRootless()
it is the wrong check to do here since we need to setup the user
namespace even in the case we are running as root without
capabilities.

[NO NEW TESTS NEEDED] this happens in nested podman

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-12-18 14:05:30 +01:00
Paul Holzinger
19457f3823 system service: split out cgroups call into linux specific file
So that we do not cause compile errors on freebsd.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-12-07 11:26:36 +01:00
Doug Rabson
43b9426fc6 cmd/podman, pkg/domain/infra: sockets should live in /var/run on FreeBSD
The /var/run directory is the preferred location for unix domain
sockets.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2023-06-29 14:52:51 +01:00