4354 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 aad29e759c78

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
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
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
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
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
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
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
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
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
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
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
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
eab03100f7 Add support, and default to rootless w/WSL prompt
Also force installation to use WSL2 to prevent accidental usage of WSL1

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-08-08 16:15:28 -04:00
f826ed5846 Disable F36 service that is incompat with WSL kern
(requires psi)

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-08-08 16:15:28 -04:00
5c95c0920f Add support for creating sigstore signatures, and providing passphrases
- Allow creating sigstore signatures via --sign-by-sigstore-private-key .
  Like existing --sign-by, it does not work remote (in this case
  because we would have to copy the private key to the server).
- Allow passing a passphrase (which is mandatory for sigstore private keys)
  via --sign-passphrase-file; if it is not provided, prompt interactively.
- Also, use that passphrase for --sign-by as well, allowing non-interactive
  GPG use. (But --sign-passphrase-file can only be used with _one of_
  --sign-by and --sign-by-sigstore-private-key.)

Note that unlike the existing code, (podman build) does not yet
implement sigstore (I'm not sure why it needs to, it seems not to
push images?) because Buildah does not expose the feature yet.

Also, (podman image sign) was not extended to support sigstore.

The test for this follows existing (podman image sign) tests
and doesn't work rootless; that could be improved by exposing
a registries.d override option.

The test for push is getting large; I didn't want to
start yet another registry container, but that would be an
alternative.  In the future, Ginkgo's Ordered/BeforeAll
would allow starting a registry once and using it for two
tests.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-08-02 16:52:56 +02:00
eacee60c83 Update c/common to an unreleased version
... to get https://github.com/containers/common/pull/1106 .

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-08-02 16:52:56 +02:00
c3e0f8ebef machine: Fix check which is always true
Before making / mutable/immutable, podman-machine checks if the mount is
being done in /home or /mnt. However the current check is always going
to be true:
```
!strings.HasPrefix(mount.Target, "/home") || !strings.HasPrefix(mount.Target, "/mnt")
```
is false when mount.Target starts with "/home" and mount.Target starts
with "/mnt", which cannot happen at the same time.

The correct check is:
```
!strings.HasPrefix(mount.Target, "/home") && !strings.HasPrefix(mount.Target, "/mnt")
```
which can also be written as:
```
!(strings.HasPrefix(mount.Target, "/home") || strings.HasPrefix(mount.Target, "/mnt"))
```

The impact is not too bad, it results in extra 'chattr -i' calls which
should be unneeded.

[NO NEW TESTS NEEDED]

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2022-07-26 14:45:12 -04:00
e6ebfbd1e0 Set TLSVerify=true by default for API endpoints
Option defaults in API must be the same as in CLI.

```
% podman image push --help
% podman image pull --help
% podman manifest push --help
% podman image search --help
```

All of these CLI commands them have --tls-verify=true by default:
```
--tls-verify  require HTTPS and verify certificates when accessing the registry (default true)
```

As for `podman image build`, it doesn't have any means to control
`tlsVerify` parameter but it must be true by default.

Signed-off-by: Vladimir Kochnev <hashtable@yandex.ru>
2022-07-26 14:44:05 -04:00
64bc2ee97f Semiperiodoc cleanup of obsolete FIXMEs
Some refer to issues that are closed. Remove them.

Some are runc bugs that will never be fixed. Say so, and remove
the FIXME.

One (bps/iops) should probably be fixed. File an issue for it, and
update comment to include the issue# so my find-obsolete-skips script
can track it.

And one (rootless mount with a "kernel bug?" comment) is still
not fixed. Leave the skip, but add a comment documenting the symptom.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-07-26 14:43:23 -04:00
c4616510a2 API: libpod/create use correct default umask
Make sure containers created via API have the correct umask from
containers.conf set.

Fixes #15036

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-07-26 14:39:39 -04:00