Commit graph

4362 commits

Author SHA1 Message Date
Lokesh Mandvekar
1f9ac52b9f
Add remote build functionality for podman-remote
(cherry picked from commit 7c2eb4006c)

This commit adds:
- Remote build implementation (build_remote.go)
- Version command for remote builds (version_remote.go)
- Fix error handling in images_build.go

Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
2026-03-30 15:13:32 -04:00
Lokesh Mandvekar
421d11529e
Add build-tagged splits for libimage-dependent code
(cherry picked from commit 4231526e18)

The common v0.57.7 vendor bump added !remote build tags to libimage,
causing podman-remote builds to fail. This change splits files that
use libimage into separate _local and _remote variants:

- pkg/specgen/specgen_{local,remote}.go: Image field storage and methods
- pkg/api/handlers/types_local.go: ImageDataToImageInspect function
- cmd/podman/utils/error_local.go: ExitCodeFromBuildError function

This allows type definitions to be shared between remote and local
builds while keeping libimage-dependent implementations local-only.

Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
2026-03-30 15:13:31 -04:00
Chris Evich
83163f87d6
Fix protobuf registration conflict by removing go-criu/v5 dependency
Commit "Fix compilation errors for v4.4.1-rhel compatibility"
introduced both go-criu/v5 and go-criu/v6 dependencies, causing a
protobuf registration conflict error:

    panic: proto: file "stats/stats.proto" is already registered
            previously from: "github.com/checkpoint-restore/go-criu/v5/stats"
            currently from:  "github.com/checkpoint-restore/go-criu/v6/stats"

Fix this by:
- Removing go-criu/v5 from go.mod
- Updating all imports from v5 to v6 in:
  * pkg/criu/criu_linux.go
  * pkg/checkpoint/crutils/checkpoint_restore_utils.go
  * test/e2e/checkpoint_test.go
- Regenerating vendor directory with 'make vendor'

Generated with the Assistance of AI: Cursor <auto>

Signed-off-by: Chris Evich <cevich@redhat.com>
2026-03-30 15:13:31 -04:00
Chris Evich
be7b956790
Fix compilation errors for v4.4.1-rhel compatibility
Align codebase with v4.4.1-rhel PodmanConfig structure
and API signatures to resolve compilation errors.

- Update all cfg.Engine.* references to
  cfg.ContainersConf.Engine.* or
  cfg.ContainersConfDefaultsRO.Engine.*
- Update all cfg.Network.* references to
  cfg.ContainersConf.Network.*
- Update all cfg.Containers.* references to
  cfg.ContainersConf.Containers.* or
  cfg.ContainersConfDefaultsRO.Containers.*
- Update cfg.Machine.* references to
  cfg.ContainersConfDefaultsRO.Machine.*
- Fix PodmanConfig initialization in config.go to use
  ContainersConf and ContainersConfDefaultsRO fields

- Add createOptions parameter to NetworkCreate method
  across all implementations (abi, tunnel, handlers)
- Update ContainerEngine interface to match new
  NetworkCreate signature
- Fix manager.Store call in secrets.go to use
  StoreOptions struct
- Update DiskUsage to handle 3 return values
- Fix NewConnectionWithIdentity call signature

- Remove duplicate setupRemoteConnection function
- Remove duplicate readRemoteCliFlags function
- Remove duplicate function declarations in
  container_path_resolution.go, oci_conmon_linux.go
- Comment out duplicate SpecGenToOCI and helper
  functions in oci.go/oci_linux.go
- Remove unused imports across multiple files
- Fix SSHMode flag handling (field doesn't exist in
  current PodmanConfig)

- Fix ns.NetNS type handling in container_internal_linux.go
- Add missing Terminal() method to Container struct
- Add missing SdNotifySocket field to ContainerConfig
- Fix DefaultCapabilities to use .Get() method
- Fix cgroups.AvailableControllers reference
- Fix ConmonPath type conversion (attributedstring.Slice)
- Add missing ErrNetworkConnected error definition
- Fix NetworkCreateOptions handling in secrets.go

- Update networking code to use getNetNSPathCommon helper
- Fix teardownNetwork method signature
- Fix makeInspectPorts to makeInspectPortBindings
- Remove hardcoded IsPasta() checks
- Fix runtime_libpod.go field access patterns

All changes align with the v4.4.1-rhel worktree structure
to ensure compatibility with upcoming cherry-picks.

Substantially Assisted-by AI: Cursor <auto>
Signed-off-by: Chris Evich <cevich@redhat.com>
2026-03-30 14:52:52 -04:00
tomsweeneyredhat
55775faaf9
Adjust for common bump
(cherry picked from commit e035eb4ffa)

The vendoring of Buildah dragged in a bump of common from v0.51.4 to
v0.57.7 which contained many changes to variable and function names.

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
Signed-off-by: Chris Evich <cevich@redhat.com>
2026-01-28 10:48:05 -05:00
Chetan Giradkar
47afed388c
Change priority for cli-flags for remotely operating
(cherry picked from commit 6597a24d6c)

... Podman
cli flags couldn't override the active-destination when env variables were set. As a remedy, the precedence of cli flags has been changed.

Note: This commit is from #19997 and it brought in some pretty massive changes
to how the remote connections are created.

Signed-off-by: Chetan Giradkar <cgiradka@redhat.com>
Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
Signed-off-by: Chris Evich <cevich@redhat.com>
2026-01-28 10:48:05 -05:00
Paul Holzinger
f78ab3435f
replace deprecated selinux/label calls
(cherry picked from commit 9b1c32869f)

These functions were removed in github.com/opencontainers/selinux
v1.12.0.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
Signed-off-by: Chris Evich <cevich@redhat.com>
2026-01-28 10:48:05 -05:00
Paul Holzinger
54bde8aa5c kube play: don't follow volume symlinks onto the host
For ConfigMap and Secret kube play volumes podman populates the data
from the yaml. However the volume content is not controlled by us and we
can be tricked following a symlink to a file on the host instead.

Fixes: CVE-2025-9566

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-09-17 08:40:37 -04:00
Ed Santiago
f3355f9591 (Temporary) Emergency CI fix: quay search is broken
Someone please revert this once quay search is fixed.

Signed-off-by: Ed Santiago <santiago@redhat.com>

<MH: Cherry-pick into v4.2.0-rhel to fix CI>

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-02-02 13:45:52 -05:00
Aditya R
75b236a2b4 compat,build: handle docker's preconfigured cacheTo,cacheFrom
Docker's newer clients popuates `cacheFrom` and `cacheTo` parameter
by default as empty array for all commands but buildah's design of
distributed cache expects this to be a repo not image hence parse
only the first populated repo and igore if empty array.

Signed-off-by: Aditya R <arajan@redhat.com>
2023-01-05 22:44:01 +00:00
tomsweeneyredhat
0f8ba63f04 [v4.2-rhel] Bump Buildah to v1.27.3
Bump Buildah to v1.27.3 which itself bumps opencontainers/selinux to
1.10.2, has fixes for the sticky bit, allows containers to be
restarted in a pod when they should be, a fix for a RHEL subscription issue,
 and s390x segv issues across RHEL 8.7 and 9.1 Zstreams

Addresses:
https://bugzilla.redhat.com/show_bug.cgi?id=2150416
https://bugzilla.redhat.com/show_bug.cgi?id=2150428
https://bugzilla.redhat.com/show_bug.cgi?id=2137294
https://bugzilla.redhat.com/show_bug.cgi?id=2149775
https://bugzilla.redhat.com/show_bug.cgi?id=2152027
https://bugzilla.redhat.com/show_bug.cgi?id=2152017
https://bugzilla.redhat.com/show_bug.cgi?id=2150433
https://bugzilla.redhat.com/show_bug.cgi?id=2150432
https://bugzilla.redhat.com/show_bug.cgi?id=2136928
https://bugzilla.redhat.com/show_bug.cgi?id=2149776
https://bugzilla.redhat.com/show_bug.cgi?id=2152026
https://bugzilla.redhat.com/show_bug.cgi?id=2152022
https://bugzilla.redhat.com/show_bug.cgi?id=2152042
https://bugzilla.redhat.com/show_bug.cgi?id=2152043

[NO NEW TESTS NEEDED]
Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2022-12-09 19:58:50 -05:00
Miloslav Trmač
02ac1c0a8f Preserve all unknown PolicyRequirement fields on (podman image trust set)
We are unmarshaling and re-marshaling JSON, which can _silently_ drop data
with the Go design decision.data.

Try harder, by using json.RawMessage at least for the data we care about.

Alternatively, this could use json.Decoder.DisallowUnknownFields.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:38 +02:00
Miloslav Trmač
5395fc7ce2 Reorganize the types in policy.go a bit
... to go from top to bottom.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:38 +02:00
Miloslav Trmač
ed3a129acf Add support for showing keyPaths in (podman image trust show)
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
dcbaf5e71b Support (image trust show) for sigstoreSigned entries
sigstoreSigned does not have GPG IDs, so we add N/A in that column.

NOTE: this does not show the use-sigstore-attachments value from
registries.d.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
80db448526 BREAKING CHANGE: Change how (podman image trust show) represents multiple requirements
Currently
- the output uses the first entry's type, even if the requirements are different
  (notably signedBy + sigstoreSIgned)
- all public keys IDs are collected to a single line, even if some of them
  are interchangeable, and some are required (e.g. two signedBy requirements
  could require an image to be signed by (redhatProd OR redhatBeta) AND (vendor1 OR vendor2)

So, stop collapsing the requirements, and return a separate entry for each one. Multiple
GPG IDs on a single line used to mean AND or OR, now they always mean AND.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
d5f34eac7b Reorganize descriptionsOfPolicyRequirements a bit
Do the registries.d lookup once, separately from building
an entry, so that we can share it across entries.

Also prepare a separate res to allow adding multiple entries.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
9bda9a6c6d Use the full descriptionsOfPolicyRequirements for the default scope
... instead of taking a shortcut, e.g. not listing any keys if they are required.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
4aefe63718 Rename haveMatchRegistry to registriesDConfigurationForScope
Just so that we don't have a boolean-named function returning a struct.
Also reorder the parameters to have the container first, and the lookup
key second.

Shoud not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
a685c89f9c Rename tempTrustShowOutput to entry
Now that it is the primary return value of a small function,
the long name only makes reading harder.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
4c1620a651 Split descriptionsOfPolicyRequirements out of getPolicyShowOutput
This will evetually allow us to use it for the default scope
as well, which currently uses a simplified version.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
cccb024d3e Recognize the new lookaside names for simple signing sigstore
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
f18066195d Add a unit test for trust.PolicyDescription
Add at least a basic unit test for the various entry types.

So that we don't have to actually deal with GPG keys and /usr/bin/gpg*,
parametrize the code with a gpgIDReader , and pass a fake one
in the unit test.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
5fbd2d4f57 Make the output of (podman image trust show) deterministic
Sort map keys instead of iterating in the Go-imposed random order.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
feff2af324 Make most of pkg/trust package-private
We now have only a few entrypoints that are called externally,
so make the rest private.  This will make it more obvious that
we are not breaking any external users.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
3b55e991bd Move most of ImageEngine.ShowTrust into pkg/trust.PolicyDescription
This will allow us to write unit tests without setting up the complete Podman runtime
(and without the Linux dependency).

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
84e122bbf2 Add support for sigstoreSigned in (podman image trust set)
NOTE: This does not edit the use-sigstore-attachments value
in registries.d, similarly to how (podman image trust set) didn't
set the lookaside paths for simple signing.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
a4f00ec361 Create new policy entries together with validating input
That way, we don't have to switch over trustType twice.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
567a0bb948 Improve validation of data in ImageEngine.SetTrust
- Also reject public keys with types that don't use them
- Reject unknown trust types
- And add unit tests

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
a1f234e141 Move most of imageEngine.SetTrust to pkg/trust.AddPolicyEntries
This will allow us to write unit tests without setting up the complete Podman runtime
(and without the Linux dependency).

Also, actually add a basic smoke test of the core functionality.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
64fdfaa9b4 Add a variable for scope
Only process the incoming args[] (which is a single-element array
for some reason) once, and use a semantic variable name for the value
we care about.

Should not change behavior, the only caller already supposedly ensures
that len(args) == 1.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
7c9f176cf8 Make trust.CreateTempFile private
Nothing uses it outside the package.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
0c8b200093 Reorganize pkg/trust
Split the existing code into policy.go and registries.go,
depending on which files it concerns.

Only moves unchanged code, should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
702b66249f Remove an unused trust.ShowOutput type
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
49ac7ee55e Remove commented out code
We can always recover it from git, but it seems to serve
no purpose anyway.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
OpenShift Merge Robot
4978898a5c
Merge pull request #16052 from openshift-cherrypick-robot/cherry-pick-16050-to-v4.2.0-rhel
[v4.2.0-rhel] Prevent nil pointer deref in GetImage
2022-10-12 10:34:29 -04:00
Matthew Heon
dce3d6ee9d Add support for containers.conf volume timeouts
Also, do a general cleanup of all the timeout code. Changes
include:
- Convert from int to *uint where possible. Timeouts cannot be
  negative, hence the uint change; and a timeout of 0 is valid,
  so we need a new way to detect that the user set a timeout
  (hence, pointer).
- Change name in the database to avoid conflicts between new data
  type and old one. This will cause timeouts set with 4.2.0 to be
  lost, but considering nobody is using the feature at present
  (and the lack of validation means we could have invalid,
  negative timeouts in the DB) this feels safe.
- Ensure volume plugin timeouts can only be used with volumes
  created using a plugin. Timeouts on the local driver are
  nonsensical.
- Remove the existing test, as it did not use a volume plugin.
  Write a new test that does.

The actual plumbing of the containers.conf timeout in is one line
in volume_api.go; the remainder are the above-described cleanups.

Backported to v4.2.0-rhel per RHBZ 2125241

Signed-off-by: Matthew Heon <mheon@redhat.com>
2022-10-06 15:07:10 -04:00
Brent Baude
94d685c0d5 Prevent nil pointer deref in GetImage
Trying to print the image id on a failed inspect will result in a nil
pointer panic because the image will be nil.  Replace image.id with the
image name which is defined as a string without the use of inspect.

Fixes: bz#2131836

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-10-05 00:54:26 +00:00
Valentin Rothberg
fb536046a3 health check: add on-failure actions
For systems that have extreme robustness requirements (edge devices,
particularly those in difficult to access environments), it is important
that applications continue running in all circumstances. When the
application fails, Podman must restart it automatically to provide this
robustness. Otherwise, these devices may require customer IT to
physically gain access to restart, which can be prohibitively difficult.

Add a new `--on-failure` flag that supports four actions:

- **none**: Take no action.

- **kill**: Kill the container.

- **restart**: Restart the container.  Do not combine the `restart`
               action with the `--restart` flag.  When running inside of
               a systemd unit, consider using the `kill` or `stop`
               action instead to make use of systemd's restart policy.

- **stop**: Stop the container.

To remain backwards compatible, **none** is the default action.

Backport of commit aad29e759c

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2097708
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-09-27 10:40:36 +02:00
Matthew Heon
21540161f2 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>
2022-09-08 15:33:29 +00:00
Brent Baude
b619c7a722 check memory test based on range
when verifying that the memory was set correctly for a podman machine
instance, we check if the number is between a range because based on
architecture, operating system, and memory itself this number can differ
significantly.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-08-10 16:46:05 -04:00
Giuseppe Scrivano
a3778b0512 specgen: use sandbox id instead of name for annotation
use the sandbox id instead of the name for the
io.kubernetes.cri-o.SandboxID annotation used by gVisor.

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

[NO NEW TESTS NEEDED] it is specific to gVisor

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-08-10 16:46:05 -04:00
Karthik Elango
a6ea3325a0 start filter flag changes
Tying filtering logic for podman stop and start to same place in getContainersAndInputByContext() to reduce code redundancy

Signed-off-by: Karthik Elango <kelango@redhat.com>
2022-08-10 16:46:05 -04:00
Paul Holzinger
bd3e36040a podman generate systemd --new: allow -h hostname
podman run/create can accept `-h <hostname>` as argument. When parsing
flags -h throws an help requested error from pflag. To prevent this
error we have to define the help flag.

Fixes #15124

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-08-10 16:46:05 -04:00
Paul Holzinger
c5c0efc95a podman generate systemd: handle --sdnotify correctly
When a container was created with `--sdnotify value` we would remove
this arg instead of using it like with `--sdnotfiy=value`.

Also when the arg is set to ignore we should force conmon in order to
make the resulting Type=notify units work.

Fixes #15052

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-08-10 16:46:05 -04:00
Jason T. Greene
8b9e5fb085 Use 8k buffer to help clients w/ broken parsing
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-08-10 16:46:05 -04:00
Daniel J Walsh
7efd81cb8d With --rm option remove container if podman run fails
Fixes https://github.com/containers/podman/issues/15049

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

<MH: Fixed cherry-pick conflicts>

Signed-off-by: Matthew Heon <mheon@redhat.com>
2022-08-10 16:46:05 -04:00
Toshiki Sonoda
b7feafcb06 Fix: manifest push --rm removes a correct manifest list
This bug is reproduced when we execute the following command:

1. podman manifest add <manifest list> <images exist on local storage>
2. podman manifest push --rm <manifest list> dir:<directory>

If pushing succeeds, it is expected to remove only a manifest list.
However, manifest list remains on local storage and images are removed.

This commit fixes `podman manifest push --rm` to remove only a manifest list.

And, supports `manifest push --rm option` in remote environment,
like host environment.

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

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2022-08-10 16:46:05 -04:00
Aditya R
9b0a1fa752 build: implement --cache-to,--cache-from and --cache-ttl
[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]

Signed-off-by: Aditya R <arajan@redhat.com>
2022-08-10 16:46:04 -04:00
Gerard Braad
6beb3f208f Fixes #15154 Change order when config and connections are written
When the break out or the WSL environment fails to start, the config
and connections should not be written. Placing them at the end of the
provisioning step will mitigate the issue.

[NO NEW TESTS NEEDED]

Signed-off-by: Gerard Braad <me@gbraad.nl>
2022-08-08 16:15:28 -04:00