Commit graph

3397 commits

Author SHA1 Message Date
Miloslav Trmač
bb1293133d Allow containerPortsToServicePorts to fail
Add an error return to it and affected callers.

Should not affect behavior, the function can't currently fail.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-12-06 15:48:44 -05:00
Valentin Rothberg
d952763884 compat: images/json
Do not list manifest lists.  Docker doesn't either.

Fixes: #12453
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-12-06 15:47:04 -05:00
Shion Tanaka
658d133390 Fixed the containerfile not found during remote build.
[NO NEW TESTS NEEDED]

Signed-off-by: Shion Tanaka <shtanaka@redhat.com>
2021-12-06 15:44:14 -05:00
Daniel J Walsh
e1cf9d4c28 Only open save output file with WRONLY
The previous code fails on a MAC when opening /dev/stdout

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

[NO NEW TESTS NEEDED] No easy way to test this.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-12-06 15:35:50 -05:00
Aditya Rajan
ab5ca6f759 compat: Add compatiblity with Docker/Moby API for scenarios where build fails
In order to maintain compatiblity with `moby API` we must the field
`errorDetail` which is primary error reporting field with stream.

Currently podman is using `error` which is already deprecated by moby.

Check: https://github.com/moby/moby/blob/master/pkg/jsonmessage/jsonmessage.go#L147

[NO NEW TESTS NEEDED]
We can't test this in podman CI since we dont have a docker client.

Signed-off-by: Aditya Rajan <arajan@redhat.com>
2021-12-06 15:33:29 -05:00
Matej Vasek
741d98fade fix: error reporting for archive endpoint
Returning 500 when copying to read-only destination.

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-12-06 15:27:55 -05:00
Urvashi Mohnani
4a7af72ea9 Add note about volume with unprivileged container
Add a note to the generated kube yaml if we detect a
volume is being mounted. The note lets the user know
what needs to be done to avoid permission denied error
when trying to access the volume for an unprivileged
container.
Add the same note to the man pages.

NO NEW TESTS NEEDED

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2021-12-06 15:17:57 -05:00
Aditya Rajan
ca518ecdee swagger: add layers to build api docs
Add missing `layer` entry to swagger docs for `/build`.

Signed-off-by: Aditya Rajan <arajan@redhat.com>
2021-12-06 15:16:10 -05:00
Aditya Rajan
a10963f2e5 compat: add layer caching compatiblity for non podman clients
Non-podman clients do not set `layers` while making request. This is
supposed to be `true` bydefault but `non-podman-clients i.e Docker` dont
know about this field as a result they end up setting this values to
`false`. Causing builds to never use cache for layers.

Adds compatiblity for `docker SDK`.

[NO NEW TESTS NEEDED]

Signed-off-by: Aditya Rajan <arajan@redhat.com>
2021-12-06 15:16:03 -05:00
Michael Scherer
2c7b673c5c Change error message for compatibility with docker
Fix #12315

Signed-off-by: Michael Scherer <misc@redhat.com>
2021-12-06 15:11:08 -05:00
Paul Holzinger
76fd7dbd15 podman machine start wait for ssh
Wait for sshd to be ready before we return from start. This should make
podman machine ssh immediately available without any race conditions.

Fixes #11532

[NO NEW TESTS NEEDED] I could not reproduce the issue so I am not sure
if this fixes it.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-12-06 15:03:07 -05:00
etenzy
0282f98b3c fix: take absolute path for dd on apple silicon
Fixes #12329

[NO NEW TESTS NEEDED] podman machine

Signed-off-by: Michael Rödel <hello@mroedel.de>
2021-12-06 15:00:47 -05:00
Giuseppe Scrivano
b5ded05f98 rootless: drop strerror(errno) calls
*printf functions already support printing the errno string with %m

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-06 15:00:29 -05:00
Giuseppe Scrivano
a92b71333e rootless: reuse existing open_namespace function
there is already a function for opening a namespace path, reuse it.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-06 15:00:23 -05:00
Giuseppe Scrivano
8e6ee43bb2 rootless: use auto cleanup functions
simplify code using auto cleanup functions

[NO NEW TESTS NEEDED] it is a refactoring of existing code

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-06 15:00:16 -05:00
Aditya Rajan
db6b9131ef secret: honor custom target for secrets with run
Honor custom `target` if specified while running or creating containers
with secret `type=mount`.

Example:
`podman run -it --secret token,type=mount,target=TOKEN ubi8/ubi:latest
bash`

Signed-off-by: Aditya Rajan <arajan@redhat.com>
2021-12-06 14:37:46 -05:00
Michael Scherer
4ed07fb67d Always create working directory when using compat API
Docker/Moby always create the working directory, and some tools
rely on that behavior (example, woodpecker/drone).

Fixes #11842

Signed-off-by: Michael Scherer <misc@redhat.com>

<MH: Fixed cherry-pick conflicts>

Signed-off-by: Matthew Heon <mheon@redhat.com>
2021-12-06 14:24:06 -05:00
Paul Holzinger
18e9ae59ca Fix network mode in play kube
We need to use the config network mode when no network mode was set. To
do so we have to keep the nsmode empty, MakeContainer() will use the
correct network mode from the config when needed.

Fixes #12248

Signed-off-by: Paul Holzinger <pholzing@redhat.com>

<MH: Fixed cherry-pick conflicts>

Signed-off-by: Matthew Heon <mheon@redhat.com>
2021-12-06 14:21:17 -05:00
Matthew Heon
57c5e2246e Swap bind address for gvproxy to localhost-only
This resolves CVE-2021-4024, where an attacker could access the
API externally and forward any port they desired to the VM from
`podman machine`.

[NO NEW TESTS NEEDED] gvproxy is not tested directly at this
time.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2021-12-03 09:50:51 -05:00
Valentin Rothberg
3912484569 systemd: replace multi-user with default.target
Replace multi-user.target with default.target across the code base.
It seems like the multi-user one is not available for (rootless) users
on F35 anymore is causing issues in all kinds of ways, for instance,
enabling the podman.service or generated systemd units.

Backport of commit 9a10e2124b.

Fixes: #12438
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-12-01 09:41:37 +01:00
Valentin Rothberg
47a8e7c9f9 container create: fix --tls-verify parsing
Make sure that the value is only set if specified on the CLI.  c/image
already defaults to true but if set in the system context, we'd skip
settings in the registries.conf.

Backport of commit ff31f2264d.

Fixes: #11933
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-11-30 14:48:26 +01:00
Jakub Dzon
b517f86334 Support env variables based on ConfigMaps sent in payload
Fixes #12363

Signed-off-by: Jakub Dzon <jdzon@redhat.com>
2021-11-30 10:44:30 +01:00
Boaz Shuster
cedf1a3d43 podman-generate-kube - remove empty structs from YAML
[NO NEW TESTS NEEDED]

Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
2021-11-12 11:08:25 -05:00
Jhon Honce
93a3e720d7 Log Apache access_log-like entries at Info level [NO NEW TESTS NEEDED]
Only log API access entries when --log-level set to Info or below.

Fixes #12181

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2021-11-12 11:08:25 -05:00
Paul Holzinger
718de67f33 Fix bindings container log test
The returned error was not checked, thus the test could hang forever
since it blocks on the log channel.

Also handle unexpectedEOF like EOF.

Fixes #12176

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-11-12 11:08:25 -05:00
Ondra Machacek
3bd80ac9ae Handle HTTP 409 error messages properly for Pod actions
This PR fixes the case when the API return HTTP 409 response. Where the
API return the body format different then for other HTTP error codes.

Signed-off-by: Ondra Machacek <omachace@redhat.com>
2021-11-12 11:08:25 -05:00
Matej Vasek
a8332f6946 Fix swagger definitions
[NO TESTS NEEDED]

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-11-12 11:08:25 -05:00
Matej Vasek
a208bc24de Set DOCKER_HOST in the VM
[NO TESTS NEEDED]

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-11-12 11:08:25 -05:00
Giuseppe Scrivano
0e1f67b725 cgroups: use SessionBusPrivateNoAutoStartup
do not start up a dbus daemon if it is not already running.

[NO NEW TESTS NEEDED] the fix is in a dependency.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-11-12 11:08:25 -05:00
Daniel J Walsh
729310a851 If Dockerfile exists in same directory as service, we should not use it.
We should only use the Containerfiles/Dockerfiles found in the context
directory.

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

[NO NEW TESTS NEEDED] It is difficult to setup a test for this in the
CI/CD system, but build tests should find if this PR broke anything.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-11-12 11:08:25 -05:00
Daniel J Walsh
8887cc7e44 podman run --memory=0 ... should not set memory limit
On Docker this is ignored, and it should be on Podman as
well. This is documented in the man page.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-11-12 11:08:25 -05:00
Stefan Weil
34739f4413 Replace 'an user' => 'a user'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2021-11-12 11:08:25 -05:00
Valentin Rothberg
9e78185e37 volumes: be more tolerant and fix infinite loop
Make Podman more tolerant when parsing image volumes during container
creation and further fix an infinite loop when checking them.

Consider `VOLUME ['/etc/foo', '/etc/bar']` in a Containerfile.  While
it looks correct to the human eye, the single quotes are wrong and yield
the two volumes to be `[/etc/foo,` and `/etc/bar]` in Podman and Docker.

When running the container, it'll create a directory `bar]` in `/etc`
and a directory `[` in `/` with two subdirectories `etc/foo,`.  This
behavior is surprising to me but how Docker behaves.  We may improve on
that in the future.  Note that the correct way to syntax for volumes in
a Containerfile is `VOLUME /A /B /C` or `VOLUME ["/A", "/B", "/C"]`;
single quotes are not supported.

This change restores this behavior without breaking container creation
or ending up in an infinite loop.

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2014149
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-11-08 10:17:06 +01:00
Aditya Rajan
5c2d17e1c1
[backport] tag: Support tagging manifest list instead of resolving to images
Following commit makes sure when buildah tag is invoked on a manifest
list, it tags the same manifest list instead of resolving to an image and
tagging it.

Backporting https://github.com/containers/podman/pull/12057

Signed-off-by: Aditya Rajan <arajan@redhat.com>
2021-11-01 17:15:59 +05:30
Daniel J Walsh
b5dd62f315 Don't use docker/pkg/archive, use containers/storage/pkg/archive
[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-10-19 15:56:35 -04:00
Giuseppe Scrivano
b470de05b0 cgroups: use cgroup.controllers to read controllers
use the cgroup.controllers file instead of cgroup.subtree_control to
read the list of controllers available in the current cgroup.

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

[NO TESTS NEEDED] we have disabled this test in the CI because it is
difficult to know what controllers are going to be enabled for
rootless under all conditions we test.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-10-19 15:56:35 -04:00
Jhon Honce
8b87793d48 Use SplitN(2) when copying env variables
Environment variables whose value contained an equal sign where
truncated

Fixes #11891

Signed-off-by: Jhon Honce <jhonce@redhat.com>

<MH: Fixed cherry-pick conflicts>

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2021-10-19 15:56:35 -04:00
Paul Holzinger
fbe94088fd podman stats: move cgroup validation to server
Podman stats is not supported for rootless cgroupv1 setups. The check
for this must be on the server side and not the client.

[NO NEW TESTS NEEDED] we cannot test this because remote and server are
always on the same machine in CI

Fixes #11909

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-10-19 15:56:35 -04:00
Reinhard Tartler
338e01f048 [CI:DOCS] oci-hooks.5.md: fixup section in header
This fixes the autodetection of where to install the manpages

Signed-off-by: Reinhard Tartler <siretart@tauware.de>
2021-10-19 15:56:35 -04:00
Matthew Heon
ca33df1468 Ensure podman ps --sync functions
The backend for `ps --sync` has been nonfunctional for a long
while now - probably since v2.0. It's questionable how useful the
flag is in modern Podman (the original case it was intended to
catch, Conmon gone via SIGKILL, should be handled now via pinging
the process with a signal to ensure it's still alive) but having
the ability to force a refresh of container state from the OCI
runtime is still useful.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2021-10-19 14:13:59 -04:00
Paul Holzinger
2cd206d0fc libpod: fix race when closing STDIN
There is a race where `conn.Close()` was called before `conn.CloseWrite()`.
In this case `CloseWrite` will fail and an useless error is printed. To
fix this we move the the `CloseWrite()` call to the same goroutine to
remove the race. This ensures that `CloseWrite()` is called before
`Close()` and never afterwards.
Also fixed podman-remote run where the STDIN was never was closed.
This is causing flakes in CI testing.

[NO TESTS NEEDED]

Fixes #11856

Signed-off-by: Paul Holzinger <pholzing@redhat.com>

<MH: Fixed cherry-pick conflicts>

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2021-10-19 14:08:58 -04:00
Jhon Honce
62d12a2adf Add guard for BuildOptions.CommonBuildOpts
Existing images.Build() bindings code panicked when field was not
initialized.

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2021-10-19 14:02:10 -04:00
Aditya Rajan
c6be71486d machine: silently cleanup dangling sockets before rm if possible
Try to cleanup dandling pid and machine socket if possible silently
before `rm`.

[NO TESTS NEEDED]

Signed-off-by: Aditya Rajan <arajan@redhat.com>
2021-10-19 14:01:27 -04:00
Urvashi Mohnani
14509a92bb Allow a value of -1 to set unlimited pids limit
Users can set --pids-limit to -1 now to set unlimited
pids limit for a container - this matches the convention.

[NO TESTS NEEDED]

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2021-10-19 13:55:41 -04:00
Brent Baude
128e168be5 Support selinux options with bind mounts play/gen
When using play kube and generate kube, we need to support if bind
mounts have selinux options.  As kubernetes does not support selinux in
this way, we tuck the selinux values into a pod annotation for
generation of the kube yaml.  Then on play, we check annotations to see
if a value for the mount exists and apply it.

Fixes BZ #1984081

Signed-off-by: Brent Baude <bbaude@redhat.com>
2021-09-30 12:06:18 -05:00
Jason T. Greene
2247d5f1b8 Disable docker and alias to podman in FCOS ignition
Signed-off-by: Jason Greene <jason.greene@redhat.com>
Co-authored-by: Dusty Mabe <dusty@dustymabe.com>
2021-09-29 16:39:29 -04:00
Ashley Cui
4fc40c82f7 Remind user to check connection or use podman machine
Remind user to check their remote linux connection or use podman
machine. Move the warning from bindings to cmd/podman.

Signed-off-by: Ashley Cui <acui@redhat.com>
2021-09-29 16:39:29 -04:00
Aditya Rajan
b3af5a92cc stop: Do nothing if container was never created in runtime
Following commit ensures we silently return container id on `stop` if
container was never created in OCI runtime.

Following behaviour ensures that we are in parity with docker.

Signed-off-by: Aditya Rajan <arajan@redhat.com>
2021-09-29 16:39:29 -04:00
Nalin Dahyabhai
7bfc5250d8 remote build: EvalSymlinks() the context directory
Use EvalSymlinks() to find the context directory, in case there's
shenanigans.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-09-29 16:39:29 -04:00
Paul Holzinger
7395459c76 podman machine: do not join userns
The go logic already prevents podman from joining the userns for machine
commands but the c shortcut code did not.

[NO TESTS NEEDED]

Fixes #11731

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-09-29 16:39:29 -04:00