Commit Graph

624 Commits

Author SHA1 Message Date
OpenShift Merge Robot fa8a3090d3 Merge pull request #1265 from ashley-cui/machvol
Add to default machine volumes for MacOS
2022-12-12 03:20:30 -05:00
Ashley Cui c92b4705d1 Add to default machine volumes for MacOS
On MacOS, mount /Users, /private/, /var/folders by default for better docker compat. The homedir on MacOS is /Users/<username>, so that will be mounted automatically anyway with this change.

Docker also mounts /Volumes and /tmp, /Volumes fails with a Too many levels of symbolic links, as Volumes on Mac is just a symlink to / which seems like a bad idea to mount anyway.
/tmp fails because the Podman machine uses the tmp directory inside the machine and writes content to it on boot, causing the mount to fail. However, on Mac, /tmp is symlinked to /private/tmp anyway, so those files are accessible from there.

Signed-off-by: Ashley Cui <acui@redhat.com>
2022-12-09 15:36:20 -05:00
OpenShift Merge Robot df2212a903 Merge pull request #1258 from Luap99/netns
pkg/netns: UnmountNS() accept netns path as string
2022-12-09 03:56:36 -05:00
Christoph Blecker 101e8f6f99 Add godoc headers for report package
Signed-off-by: Christoph Blecker <cblecker@redhat.com>
2022-12-07 13:21:17 -08:00
Paul Holzinger 70d14082ea pkg/netns: UnmountNS() accept netns path as string
I want to switch podman over to only using strings for the netns path.
So we no longer pass this interface around. Buildah doesn't use this so
we only need to fix it in Podman. I have a WIP PR[1] for that.

[1] https://github.com/containers/podman/pull/16756

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-12-07 14:53:47 +01:00
OpenShift Merge Robot a4cd996652 Merge pull request #1252 from rhatdan/caps
Rework default list of capabilities to minimal
2022-12-06 09:17:16 -05:00
Daniel J Walsh ad04f58f7a Vendor in latest containers/(storage, image)
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-12-05 10:04:10 -05:00
OpenShift Merge Robot 2ecf4da04b Merge pull request #1251 from rhatdan/readonly
Add ReadOnly flag to run containers in readonly mode
2022-12-05 08:07:57 -05:00
Daniel J Walsh e2fb8c5133 Add ReadOnly flag to run containers in readonly mode
This is needed for Automotive.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-12-05 06:05:56 -05:00
Giuseppe Scrivano 10d63bf089 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/16718

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-12-05 09:54:03 +01:00
Daniel J Walsh c552ab433d Revert "Revert "Rework default list of capabilities to minimal""
This reverts commit 91ba27095f.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-12-04 16:12:04 -05:00
OpenShift Merge Robot 23636dda9a Merge pull request #1243 from vrothberg/RUN-1702
containers.conf: add events_container_create_inspect_data
2022-11-28 07:44:29 -05:00
Valentin Rothberg 821a0657ca containers.conf: add events_container_create_inspect_data
Add an option to create a more verbose container-create event which
includes a JSON payload with detailed information about the container.

Jira: https://issues.redhat.com/browse/RUN-1702
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-11-28 13:01:46 +01:00
Daniel J Walsh f8045ec731 Remove conmon probe
This is taking time on every podman call, and provide limited
protection. Versioning should be handled in the packaging system
and this is an unlikely to happen.

Every exec done by container tools hurts us as we try to get container
startup team to absolute minimal amounts.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-11-27 07:16:29 -05:00
Valentin Rothberg 91ba27095f Revert "Rework default list of capabilities to minimal"
This reverts commit 962dbc3281.
As shown in containers/podman/pull/16610 the changes require a number of
changes in Podman's CI.  While many issues have been fixed in that PR,
there are some potentially controversial changes such as dropping
NET_RAW.

Let's revert the commit to unblock ongoing work.  For the next
iteration, Podman CI must be green before merging.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-11-25 09:37:41 +01:00
OpenShift Merge Robot 32d0d9fc59 Merge pull request #1239 from giuseppe/validate-cdi-devices
validate: ignore validation of CDI devices
2022-11-23 04:55:47 -05:00
OpenShift Merge Robot 5034979776 Merge pull request #1240 from rhatdan/caps
Rework default list of capabilities to minimal
2022-11-23 03:39:04 -05:00
Daniel J Walsh 962dbc3281 Rework default list of capabilities to minimal
For a couple of years now we have been shipping containers.conf settings
to use only 10 capabities. Docker uses 14, with the difference being
CAP_AUDIT_ALLOW, CAP_NET_RAW, CAP_MKNOD, CAP_CHROOT.

This allows us to run with a tighter security then Docker.

This PR makes the change to default config, so that if no
containers.conf overrides are present, we will run with the tighter
security. Currently most distros that ship the containers.conf already
run with this setting, but this makes it formal, and changes the man
page to match the defaults.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-11-22 12:55:25 -05:00
Giuseppe Scrivano 76d4399a75 validate: ignore validation of CDI devices
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-11-21 22:40:48 +01:00
Daniel J Walsh 3a429400c3 Deprecate UserNSSize, since we don't use it
Podman and Buildah do not use this field, and I
know of no users of it, remove it from docs and
the default conf file, so users will not expect
it to do anything.

Leaving implementation in the slight chance someone
has used it in a non containers project.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-11-21 13:06:10 -05:00
OpenShift Merge Robot 43bae401c0 Merge pull request #1225 from flouthoc/platform-to-oci-runtime
config: add support for `platform_to_oci_runtime` and default entries for `wasi/wasm`
2022-11-11 16:04:27 +00:00
Aditya R 1ea30aa853 config: add support for platform_to_oci_runtime and default entries for wasm
Containers.conf now supports `platform_to_oci_runtime` which allows end
users to map variant of OCI runtime for a particular platform.

Most ideal use-case of this feature is switching to crun's variant when
platform string is `wasm32/wasi`.

Example
```toml
[engine.platform_to_oci_runtime]
"wasi/wasm" = "crun-wasm"
"wasm/wasm32" = "crun-wasm"
"wasm/wasm64" = "crun-wasm"
```

Signed-off-by: Aditya R <arajan@redhat.com>
2022-11-11 20:44:59 +05:30
Doug Rabson 4b906d8159 pkg/config: Fix DefaultSignaturePath on FreeBSD
The correct location on FreeBSD is /usr/local/etc/containers/policy.json
which is consistent with path conventions for installed packages. This
fixes 'podman commit' on FreeBSD.

There are several definitions of this path:

- c/image/signature has builtinDefaultPolicyPath and DefaultPolicy
- c/podman/pkg/trust has systemDefaultPolicyPath and DefaultPolicyPath
- c/common/pkg/config has DefaultSignaturePolicyPath

As far as I can tell, buildah uses c/image/signature which is why 'buildah
commit' was already working for me. Podman is using the c/common one. Very
confusing.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-11-09 16:50:45 +00:00
Paul Holzinger ebe2c6ab9f pkg/report: fix IsJSON() #2
The PR #1226 was merged to soon, it breaks podman tests and backwards
compat. `{{json}}` and `{{json.}}` are not valid templates but it worked
before the same as `json` so we should keep that for compat reasons.

Fixes up commit 44757e2c3d

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-11-08 18:08:15 +01:00
Paul Holzinger 44757e2c3d pkg/report: fix IsJSON()
When a user request --format `{{json .}}` they would want the go
template parser to handle it. Currently we overwrite this and assume
that `{{json .}}` equals `json`. This is not correct. When the output is
a range (array), i.e. podman ps, it should return one json object per
line and not a json array which is the case with `json`.

This is required for docker compat.

Fixes containers/podman#16436

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-11-08 14:19:45 +01:00
Daniel J Walsh 488fb367e7 create known_hosts file path when missing
Fixes: https://github.com/containers/podman/issues/16340

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-11-04 08:30:42 -04:00
unknowndevQwQ 5db50a2cb8 feat: add support for the youki OCI Runtime 2022-10-22 10:35:23 +08:00
Doug Rabson 8d0af4f01e config: Add config entry for ocijail
Another experimental OCI runtime for FreeBSD, similar to runj but with
a focus on podman/buildah compatiblity.

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-10-19 12:02:47 +01:00
Valentin Rothberg e17483b871 bump to golangci-lint v1.50.0
Used `go fmt` rules to migrate away from deprecated functions, for
instance `gofmt -w -s -r 'ioutil.TempDir(a, b) -> os.MkdirTemp(a, b)'`

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-10-17 15:03:07 +02:00
Daniel J Walsh fc1a4a31ee Vendor in latest containers/(storage, image) and runtime-tools
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-10-14 09:58:29 -04:00
Jason T. Greene 45154dcc7e Fix Windows regression introduced by PR #1161
Before 50eb74a4b1 this code used unshare.IsRootless() which on Windows
always returns false (the behavior we want).

After 50eb74a4b1, a condition was unintentionally inverted, allowing
Windows to function.

Commit 18803495e8 fixed the inversion, but unintentionally excluded Windows
since it used == 0 instead of <= 0 (Windows returns -1)

Move the logic behind a function with a comment since the Windows path is a
bit exotic.

In the future, the Windows path should likely be refactored to be more
intuitive; however, this will get things working for now.

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-09-29 15:39:23 -05:00
Aditya R aa2831dc24 util, GetRuntimeDir: don't error out early if XDG_RUNTIME_DIR is not found
We must try out all possible alternatives for rootless users instead of
failing eary if XDG_RUNTIME_DIR is not set.

Following regression was part of: 5948e6b369

[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]

Signed-off-by: Aditya R <arajan@redhat.com>
2022-09-29 14:08:16 +05:30
OpenShift Merge Robot 13850996f1 Merge pull request #1162 from rhatdan/XDG_RUNTIME_DIR
Eval symlinks on XDG_RUNTIME_DIR
2022-09-26 22:39:45 +02:00
Charlie Doern 2b86bc5d8a podman machine and podman-remote need some softer handling when it comes to key verification
this ensures that podman machine will still work (until we want to make this mandatory). I made the call back function more verbose so we know what is happening from now on.

Signed-off-by: Charlie Doern <cdoern@redhat.com>
2022-09-26 15:36:00 -04:00
Daniel J Walsh 5948e6b369 Eval symlinks on XDG_RUNTIME_DIR
Partial Fix for containers#14606

[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-09-23 14:06:26 -04:00
Giuseppe Scrivano 18803495e8 config: correct the check for root
originally the code had the condition "!unshare.IsRootless()", and
commit 50eb74a4b1 introduced the issue
by replacing it with "unshare.GetRootlessUID() != 0".

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-09-20 17:14:48 +02:00
Giuseppe Scrivano 50eb74a4b1 config: look user id instead of rootless
Change the check to look for the UID to decide whether to load the
default configuration files from the user directory instead of the
system path.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-09-16 16:46:09 +02:00
OpenShift Merge Robot 26ec6002bb Merge pull request #1150 from ashley-cui/secretsapi
Use StoreOpts for secret store API
2022-09-09 21:08:43 +02:00
Ashley Cui 0c92aa20b2 Use StoreOpts for secret store API
Clean up store code by using StoreOpts instead of multiple args as opts
for storing secrets.

Signed-off-by: Ashley Cui <acui@redhat.com>
2022-09-09 11:15:41 -04:00
Paul Holzinger 7fff18ce94 phg/config: do not force default EventsLogFilePath
The problem with setting such defaults in c/common is that podman cannot
know if a user set this or it is the default. EventsLogFilePath is not a
static path, it depends on the --tmpdir value from podman.

check
b0b36430b8/libpod/runtime.go (L1041-L1043)

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-09 15:07:58 +02:00
Ashley Cui 104bc604d4 Add labels to secrets
Allow secrets to be labeled. Add new field in secrets package called
label.

Signed-off-by: Ashley Cui <acui@redhat.com>
2022-09-07 14:48:44 -04:00
Paul Holzinger 12e4bd7fdb pkg/report: handle newline in template string
Docker tries to be smart and replaces \n with the actual newline character.
For compat we do the same but this will break formats such as '{{printf "\n"}}'
To be backwards compatible with the previous behavior we try to replace and
parse the template. If it fails use the original text and parse again.

This fix will not be enough. It requires many changes in podman since
most commands will do their own NormalizeFormat() call before using this
backend which seems wrong and creates a lot of duplication. This has to
be fixed in Podman.

Required for https://bugzilla.redhat.com/show_bug.cgi?id=2059658
and https://github.com/containers/podman/issues/13446.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-06 13:24:29 +02:00
Giuseppe Scrivano 06204cbe5e cgroup: do not fail with missing cpuset file
if cpuset.cpus[.effective] file is missing, then ignore the error
since it means the cpuset controller is not enabled in the kernel,
rather than returning an error.

Closes: https://github.com/containers/common/issues/1134

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-08-30 10:45:27 +02:00
OpenShift Merge Robot 278ea68e45 Merge pull request #1137 from dfr/freebsd-config
Change default cgroups mode to enabled on FreeBSD
2022-08-29 06:30:32 -04:00
Daniel J Walsh a5698c8b06 Fix stutters
Podman adds an Error: to every error message. So starting an error
message with "error" ends up being reported to the user as

Error: error ...

This patch removes the stutter.

Also ioutil.ReadFile errors report the Path, so wrapping the err message
with the path causes a stutter.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-08-27 08:05:03 -04:00
Doug Rabson ccbe0c12ac Change default cgroups mode to enabled on FreeBSD
Setting it to disabled triggers NoCgroups logic in podman which adds
extra validation and changes the conmon command line in ways that are
messy to work around. It turns out that pretending cgroups is enabled
even though the platform doesn't support it is easier.

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-08-27 11:14:54 +01:00
OpenShift Merge Robot af3185ad19 Merge pull request #1119 from rhatdan/path
Add support for returning image path with ARCH and OS Substitutions
2022-08-23 09:06:05 -04:00
Filipe Brandenburger bd82c36998 config: Update Darwin config to include a directory relative to $BINDIR
Look for helpers such as `gvproxy` under `$BINDIR/../libexec/podman`, which
helps this work on distributions such as Homebrew without the need to hardcode
paths into the binary, which makes a pre-built binary distribution work
regardless of the installation prefix.

Tested: Updated vendored package in podman, built it with `podman-remote`,
copied `gvproxy` to a `libexec/podman` at the same level as `bin/podman` and
confirmed that `podman machine start` worked as expected.

Signed-off-by: Filipe Brandenburger <filbranden@gmail.com>
2022-08-22 13:28:00 -07:00
Filipe Brandenburger de5bad0cc3 config: Allow specifying helper dirs with $BINDIR as base directory
This should make it easier to locate helper binaries relative to where the main
binary was installed, which should be useful in installations such as Homebrew
which install packages under a versioned directory.

Use a `$BINDIR` magic token as a prefix in the helper path to indicate it should
be relative to the directory where the binary is located. This is somewhat familiar
to the syntax used in the shell and Makefile and is still quite explicit about the
behavior (as opposed to, say, making all relative paths be relative to the directory
of the binary.)

Tested: After updating the Darwin config to include a `$BINDIR/../libexec/podman`
directory, updated vendored package in podman, built it with `podman-remote`,
copied `gvproxy` to a `libexec/podman` at the same level as `bin/podman` and
confirmed that `podman machine start` worked as expected. Also confirmed that
having the `podman` in search path be a symlink to a binary elsewhere works as
expected, the searched `../libexec/podman` directory is relative to the actual
binary and not the symlink (which matches the Homebrew use case.)

Signed-off-by: Filipe Brandenburger <filbranden@gmail.com>
2022-08-22 13:28:00 -07:00
OpenShift Merge Robot 07298b23a3 Merge pull request #1129 from mheon/add_volume_timeout
Add volume plugin timeout to containers.conf
2022-08-22 15:43:51 -04:00