Commit Graph

239 Commits

Author SHA1 Message Date
Doug Rabson 478419732a Change default image volume mode to "nullfs" on FreeBSD
This fixes a regression in
https://github.com/containers/podman/pull/19241 which quite reasonably
assumed that the default image volume mode from pkg/config was correct.

Signed-off-by: Doug Rabson <dfr@rabson.org>
2023-07-17 14:58:23 +01:00
Lokesh Mandvekar 4bb9e26054 containers.conf: Add `podmansh_timeout`
Ref: https://github.com/containers/podman/pull/19140#discussion_r1254435823

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2023-07-14 15:19:11 -04:00
Giuseppe Scrivano 518758c4c7 config: add CompressionLevel to containers.conf
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-06-21 12:05:52 +02:00
Paul Holzinger c0a7616486 pkg/config: add default_rootless_network_cmd field
Add a new field to the network section to allow users to set the default
network program which is used when running rootless containers.
This should be used when you run something like --network private or
--network default as rootless user.

The current default is slirp4netns so we keep that for now. Once I
integrate pasta in the rootless netns then we can consider switching the
default to pasta.

This setting will also be useful then for distros who may not ship pasta
so that they could set it back to slirp if needed.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-23 13:40:23 +02:00
Paul Holzinger 2b8784dad0 pkg/config: add pasta_options field
Users way wish to configure a set of default options that should be used
when running pasta. Options that are given on the cli will be appended,
however the implementation of this needs to happen in podman.

For slirp4netns we already support the network_cmd_options field.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-23 13:40:22 +02:00
Daniel J Walsh ed8be0d003 Add support for confined SELinux users
The original SELinux support in Docker and Podman does not follow the
default SELinux rules for how label transitions are supposed to be
handled. Containers always switch their user and role to
system_u:system_r, rather then maintain the collers user and role.
For example
unconfined_u:unconfined_r:container_t:s0:c1,c2

Advanced SELinux administrators want to confine users but still allow
them to create containers from their role, but not allow them to launch
a privileged container like spc_t.

This means if a user running as
container_user_u:container_user_r:container_user_t:s0

Ran a container they would get

container_user_u:container_user_r:container_t:s0:c1,c2

If they run a privileged container they would run it with:

container_user_u:container_user_r:container_user_t:s0

If they want to force the label they would get an error

podman run --security-opt label=type:spc_t ...

Should fail. Because the container_user_r can not run with the spc_t.

SELinux rules would also prevent the user from forcing system_u user and
the sytem_r role.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-05-03 15:00:26 -04:00
Jason T. Greene f12270cfea Use atomic write strategy for config files
Updates to containers/storage@main
(contains a required fswriters PR: containers/storage#1554)

[NO NEW TESTS NEEDED]

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2023-04-06 17:11:29 -05:00
Paul Holzinger 7966ad46e4 pkg/config: add netavark_plugin_dirs fields
Add config field to specify the location for the netavark plugins.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-04-04 18:20:12 +02:00
Urvashi Mohnani bd4cc572c6 Add kube_generate_type to set default for kube generate
The kube_generate_type field can be used to set what kind
of k8s object, i.e pod or deployment, that the podman kube
generate command should generate by default.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-04-03 13:19:23 -04:00
Erik Sjölund 1d3eb27001 Fix typos and other minor language issues
Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
2023-04-02 14:17:28 +02:00
Valentin Rothberg 20e578d5b9 pkg/config: add CONTAINERS_CONF_OVERRIDE
Add yet another environment variable for loading containers.conf.
When CONTAINERS_CONF_OVERRIDE is set, the specified config file
will be loaded last - even when CONTAINERS_CONF is set.

This mechanism is needed to preserve system settings and other
environment variables.  Setting CONTAINERS_CONF will load only
the specified config file and ignore all system and user paths.
That makes testing hard as many Podman tests use CONTAINERS_CONF
for testing.

The intended use of CONTAINERS_CONF_OVERRIDE is to set it during tests
and point it to a specific configuration of Podman (e.g., netavark with
sqlite backend).

Similar needs have popped up talking to users in the automotive and
high-performance computing space.  In a way, such a setting allows for
specifying a specific "flavor" of Podman while preserving all existing
settings on the system.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-03-23 13:48:39 +01:00
Daniel J Walsh 8ff9776671 Add oom_score_adj to set default oom score adj
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-03-15 17:28:59 -04:00
Daniel J Walsh 99fbba5ca3 Allow cgroup-conf settings to be stored in containers.conf
This will allows users to set all containers to automatically
set certain cgroup fields globally for all of their containers.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-03-14 16:35:54 -04:00
Valentin Rothberg ac12d8f273 containers.conf: add database backend option
The on-going work of adding a new database backend to Podman requires it
to be configurable in containers.conf.  To prevent any breaking changes,
the backend defaults to Podman's current boltdb backend.  Also export
the parsing function for it be usable by Podman.

NOTE: documentation will be added once the database rewrite in Podman
has been completed.  I want to avoid any incomplete docs from leaking
into a release.

Fixes: https://issues.redhat.com/browse/RUN-1772
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-02-20 13:00:13 +01:00
Arthur Sengileyev ba9896d094 FindHelperBinary will try LookPath of absolute path
exec.LookPath seems to handle absolute paths gracefully. On Windows this
allows to additionally check for all known executable alternatives
when only name is provided.

Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
2023-02-12 17:51:23 +02:00
Arthur Sengileyev 2a658cadb2 Add Provider to MachineConfig
Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
2023-01-22 00:08:37 +02: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
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
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
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 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
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
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 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
Matthew Heon 4f7bd530ae Add volume plugin timeout to containers.conf
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2022-08-22 14:39:23 -04:00
Daniel J Walsh 3196de901c Add support for returning image path with ARCH and OS Substitutions
Allow distributions to specify the location of the podman image VM
images in the form of URIs with $ARCH and $OS specified.  This would
allow a distribution to pull the image based on the current OS and Arch.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-08-22 07:17:58 -04:00
Jake Correnti 5128b5a72f Add conmon-rs paths
Adds the conmon-rs paths so Podman can find the right conmon-rs binary
when making a new runtime.

I also slightly modified the `FindConmon` function so that the code
could be shared with the `FindConmonRs` function that I added.

Signed-off-by: Jake Correnti <jcorrenti13@gmail.com>
2022-08-10 10:46:26 -04:00
Charlie Doern 64be63d976 ssh package
initial implementation of the ssh package including:

- nativeConnectionCreate() / golangConnectionCreate()
- n/a / golangConnectionDial()
- nativeConnectionScp() / golangConnectionScp()
- nativeConnectionExec() / golangConnectionExeC()

the way this works, is there are publicly accessible functions Create, Exec, Dial and Scp. podman will have a new global flag --ssh` that will allow users to choose native or golang based ssh functions. The functionality in containers/common (here) also checks if you have the necessary binaries installed

closes #1091

Signed-off-by: Charlie Doern <cdoern@redhat.com>
2022-08-08 09:22:46 -04:00
openshift-ci[bot] 765893536d Merge pull request #1077 from saschagrunert/errors
Switch to golang native error wrapping
2022-07-12 11:21:37 +00:00
Sascha Grunert 426d69c00f Switch to golang native error wrapping
`github.com/pkg/errors` is deprecated since quite some time so we now
use the native error wrapping for more idiomatic golang.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-07-12 10:54:07 +02:00
Dominique Martinet 2e8943d3f7 add network dns_bind_port setting and set NETAVARK_DNS_PORT from it
This commit allows using aardvark with an alternate port as per
implementation in containers/netavark#323

Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
2022-07-08 09:45:15 +09:00
Daniel J Walsh a390d0c66c Change github.com/pkg/errors to use errors in pkg/config
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-05-18 10:33:53 -04:00
Daniel J Walsh 58f58410a6 Support setting image_volume_mode in containers.conf
Begins to fix https://github.com/containers/podman/issues/14230

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-05-18 10:10:06 -04:00
Kir Kolyshkin 27bf522212 .golanci-lint: enable gofumpt
gofumpt is more opinionated version of gofmt. One can use it from their
$EDITOR, or IDE, or gopls to better format the source code.

Previously, commit b951b72412 already formatted all the code with
gofumpt, but since then a couple of things crept in.

Fix these (with gofumpt v0.3.1) and enable the gofumpt linter.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-05-16 20:01:08 -07:00
Doug Rabson a4a658034b Config files should live in /usr/local on FreeBSD
Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-05-09 14:07:58 +01:00
Doug Rabson faf3c75d8f Add runj which is an experimental OCI runtime based on FreeBSD jails
Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-05-09 14:07:58 +01:00
OpenShift Merge Robot 030366b89e Merge pull request #1024 from Luap99/linters
enable unparam, exportloopref and revive linters
2022-05-06 08:57:16 -04:00
Paul Holzinger cc110440e4 enable unparam, exportloopref and revive linters
unparam and exportloopref already work without changes.
For revive I had to silence many naming issues. I decided to silence them
instead of changing the name because I didn't want to break any code.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-05-06 13:32:35 +02:00
Valentin Rothberg 1cb045b421 containers.conf: add pod_exit_policy
Add a new `pod_exit_policy` field to the containers.conf's engine table.
A pod's exit policy determines the behaviour when the last container of
a pod exits.

Required-in: containers/podman/pull/13859
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-04-29 12:17:16 +02:00
Jason T. Greene 77d8f70039 Deprecate MachineEnabled and replace with API
machine.IsPodmanMachine replaces MachineEnabled
machine.MachineHostType informs the type unknown, qemu, wsl, etc
machine.IsGvProxyBased used to make specific determinations re gvproxy

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-04-23 12:32:54 -05:00
Paul Holzinger ce62c07f22 add host_containers_internal_ip to containers.conf
Set the ip for the host.containers.internal entry in the containers /etc/hosts
file. This can be set to "none" to disable adding this entry. By default it
will automatically choose the host ip.

Also add a function to get the correct host.containers.internal ip. This
should be used by podman and buildah and then passed to the New()
function.

Ref https://github.com/containers/podman/issues/13224

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-21 11:48:36 +02:00
Paul Holzinger a3b0ae033e add base_hosts_file field to containers.conf
base_hosts_file can be used to overwrite the default base host file
/etc/hosts which is used to copy hosts entries from this file into the
containers /etc/hosts file. As special value "image" can be used to copy
the entries from the image hosts file or "none" to not use a base file
at all. IF the value is empty we should use /etc/hosts as default.

Ref https://github.com/containers/podman/issues/13277
Ref https://github.com/containers/podman/issues/13748

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-21 11:39:56 +02:00
Niall Crowe a894dd11a3 pkg/config: new value for events_logfile_max_size
Changing the value for events_logfile_max_size from 0 to 1048576. This allows
up to 10,000 events to be written to the events log file before rotation occurs.
Also adding new values to default.go

Signed-off-by: Niall Crowe <nicrowe@redhat.com>
2022-04-20 10:23:50 +01:00
OpenShift Merge Robot 6c2cd2f357 Merge pull request #997 from kolyshkin/golangci-lint
golangci-lint spring cleaning and bump
2022-04-14 07:14:51 -04:00
Daniel J Walsh a3e25551d0 Add machine volumes to containers.conf
This will allow users to specify which volumes they want podman machine
to automatically mount into the machine. These volumes can later be used
to volume mount into containers.

Environment variables like $HOME can be used and are translated at the
time of machine start.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-04-13 07:33:17 -04:00
Kir Kolyshkin b951b72412 Gofumpt the code
gofumpt is a stricter version of gofmt, basically making the code more
readable, and fixing the gocritic's octalLiterar warnings like this one:

	pkg/util/util_supported.go:26:17: octalLiteral: use new octal literal style, 0o722 (gocritic)
		return (perm & 0722) == 0700
			       ^

Generated by gofumpt -w .

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-04-09 16:50:11 -07:00
Daniel J Walsh a4a20e5973 Switch all calls to filepath.Walk to filepath.WalkDir
Eliminating all of the stat calls should make this a bit faster.

[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-03-26 06:53:11 -04:00
Paul Holzinger 205fcae97e pkg/config: events_logfile_max_size add omitzero
Number types must use omitzero otherwise they are included in the toml
file when it is written and the value is 0, see commit 6c61942524.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-03-24 16:13:19 +01:00
Niall Crowe ccad158a8b containers.conf: add events_logfile_max_size
Add a new option to the `[engine]` table in containers.conf
for specifying the maximum size of `events_logfile_path`.
Once exceeded, Podman will rotate the logfile and delete
the old one.

Also add tests to make sure we're not regressing in the future.

Signed-off-by: Niall Crowe <nicrowe@redhat.com>
2022-03-16 14:32:59 +00:00
Rover van der Noort 87dcc5729f Add ExitCommandDelay as configuration in EngineConfig with default of 5 minutes in seconds.
Signed-off-by: Rover van der Noort <s.r.vandernoort@student.tudelft.nl>
2022-02-24 15:51:05 +01:00
Paul Holzinger b76062811b pkg/config: add new default_subnet_pools field
Add a new field to set the default subnet pools. They can be used to
change the subnet which is automatically allocated by podman network
create.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-02-15 15:29:19 +01:00
Daniel J Walsh 3e33e53044 Run codespell on code
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-01-21 07:47:02 -05:00
Paul Holzinger 4eb265ce95 remove rootless_networking field from containers.conf
This field was only needed for machine to force cni, however you can set
netns="bridge" in the config to have the same effect. This is already
done in the machine setup.

The field was more of a hack and just creates confusion for users so we
remove it.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-20 16:23:12 +01:00
OpenShift Merge Robot c0b7992982 Merge pull request #887 from machacekondra/configmap
Add configmap backend
2022-01-19 10:37:02 -05:00
Paul Holzinger 995cdaae8f netavark: use globally shared network config dir
Since the network namespace is shared for all rootful libpod instances
we also need to make sure to use the same network config dir and run dir
to ensure that we do not use the same subnet or ip for more than one
container.

Also update the documentation about the network_config_dir field.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-17 15:36:03 +01:00
Ondra Machacek db55cb361b Add configmap backend 2022-01-14 09:56:51 +01:00
Daniel J Walsh f92d49848e No reason to use a Map versus a slice for ProxyEnv
[NO NEW TESTS NEEDED]

Also vendor in latest containers/image code to remove dependabot
warnings.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-01-07 09:20:54 -05:00
Daniel J Walsh 98b9bd7d43 WEB Proxy is used in at least three different places in code
This change makes a global rather then defining this list in multiple
places.

[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-01-07 08:43:38 -05:00
Jason T. Greene d813c5e6fb Add platform driven image and user defaults for podman machine
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2021-12-09 14:37:54 -06:00
Giuseppe Scrivano f0262407d0 config: add CompressionFormat option
support changing the default compression format in the containers.conf
config file.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-02 15:56:43 +01:00
Valentin Rothberg c9748ff5ad containers.conf: add option to enforce docker.io for compat API
Add an option to containers.conf as a knob to enforce short-name
resolution to Docker Hub in Podman's compatibility REST API.

By popular request, turn it on by default.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-11-19 16:44:56 +01:00
Daniel J Walsh 6d6fe11781 Set the environment variables for the engine
The Engine.Env needs to be set very early in the setup process
to make sure no one attempts to use the environment.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-11-15 12:03:40 -05:00
Ed Santiago c55ef5b984 FindHelperBinary(): allow override via envariable
When searching for helpers, check $CONTAINERS_HELPER_BINARY_DIR.
If it points at an existing directory, prepend it to the
search path for binaries.

Intention is to use this for developer testing: a way to run make
(e.g. in podman) then use the locally-built rootlessport and pause
images

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-11-11 12:26:38 -07:00
Matthew Heon 8b1b879924 Add network_backend field for switching to netavark
This field determines whether CNI or netavark will be used to
create container networks. Default presently set to "cni".

Signed-off-by: Matthew Heon <mheon@redhat.com>
2021-11-09 13:45:56 -05:00
Daniel J Walsh 9680fe7bf6 Update pkg/config/config.go
Co-authored-by: Valentin Rothberg <rothberg@redhat.com>
2021-10-25 12:36:34 -04:00
Jacob Emmert-Aronson 8d0bbae800 Add a hint for misconfigured helper_binaries_dir
Signed-off-by: Jacob Emmert-Aronson <jacob@roadnottaken2718.com>
2021-10-23 14:50:57 -07:00
Valentin Rothberg 44f8339664 containers.conf: unknown keys: reduce to Debug level
Reduce the logs for unknown keys from Warn to Debug level.
The containers.conf continuously receives new keys, and some consumers
(e.g., Podman) are updating it at runtime.  Even small divergences in
the vendored versions of containers/common can let one tool run fine and
the other print warnings for each invocation.  Reducing the log-level to
debug works around that problem at the cost of honest typos not being
as easy to detect as before.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-10-08 13:02:25 +02:00
Paul Holzinger 6c61942524 config: add omitzero for numeric types
When toml writes the config file it does not use `omitempty` for numeric
values instead it requires `omitzero`. [1]

The problem is that without this change, `config.Write()` writes
```
[machine]
  cpus = 0
  disk_size = 0
  memory = 0
```
to the user file. Because podman machine system connection add code will
do this the config file is broken afterwards. The first vm will be created
successfully but after this every other vm will be broken because the
cpu, memory and disk size are set to zero.

[1] https://github.com/BurntSushi/toml/pull/81

Fixes containers/podman#11824

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-10-01 15:13:02 +02:00
Ashley Cui bb2b17e7da Add machine table to containers.conf
Add machine teable to configure podman machine options. Move machine_image to the machine table, and add cups, disk size, and memory to the machine table.

Signed-off-by: Ashley Cui <acui@redhat.com>
2021-09-23 17:03:12 -04:00
Daniel J Walsh b45ac6d515 Make podman system service timeout configurable in containers.conf
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-09-15 06:15:42 -04:00
Daniel J Walsh a5bac2096a Add support for image_copy_tmp_dir
Allow users to set the default location for the temporary files used
during image pulls and pushes.

Defaults to /var/tmp;

Overridden via "TMPDIR" environment variable.

Allow special flag "storage" to indicate the the storage should use
the tmp directory in containers/storage/tmp.

Needed to fix: https://github.com/containers/podman/issues/11107

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-09-11 04:51:27 -04:00
Paul Holzinger 25622da26e Add HelperBinariesDir field to engine config
This field contains a list of directories which should be used to store
some helper binaries, e.g. gvproxy.

Also add a FindHelperBinary method to the config struct to get the full
path to a helper binary.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-09-10 13:38:19 +02:00
Matthew Heon 92ebb4a858 Switch default Rootless Networking to "CNI" for OSX
This should better support rootless CNI usescases.

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

Signed-off-by: Matthew Heon <mheon@redhat.com>
2021-09-01 15:57:00 -04:00
unknowndevQwQ 43bd1ced8a add some cni plugin paths
add some possible paths for the cni plugin to be stored

Replaces: containers/common#728

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-08-31 06:23:16 -04:00
Ashley Cui 927da0ce99 Add machine_image to containers.conf
Signed-off-by: Ashley Cui <acui@redhat.com>
2021-08-09 15:37:06 -04:00
unknowndevQwQ 1826e711c7 fix: fix #692 2021-08-02 21:43:06 +08:00
Giuseppe Scrivano d7e8c2338b config: split arguments in DBUS_SESSION_BUS_ADDRESS
split the DBUS_SESSION_BUS_ADDRESS value so that something like:

unix:path=/run/user/1000/bus,guid=817e9ffcfb383869ad17ea8360e7428a

will ignore ",guid=817e9ffcfb383869ad17ea8360e7428a" when checking
that the path exists.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1984531

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-07-26 15:08:33 +02:00
OpenShift Merge Robot 33633ba029 Merge pull request #678 from vikas-goel/prepare-volume
User option to prepare container after creation for volume copy-up.
2021-07-15 09:22:09 -04:00
Vikas Goel a7668c208f User option to prepare container after creation for volume copy-up.
Docker does this by default.

Relates to podman#10262

[NO TESTS NEEDED]

Signed-off-by: Vikas Goel <vikas.goel@gmail.com>
2021-07-14 12:12:15 -07:00
Matej Vasek 61d2ae986d add config option for ChownCopiedFiles
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-07-13 18:17:12 +02:00
Daniel J Walsh 001e09ea34 Report bad entries in containers.conf to the user
Currently if a user puts a typo into a contianers.conf
or puts the keys in the wrong section, then tools using
container-common ignore them. This patch will print them
as warnings, so that the user has some ide.

I have tested this locally with Podman.
./bin/podman run alpine echo hi
WARN[0000] Failed to decode the keys ["containers.events_logger" "engine.foo"] from "/home/dwalsh/.config/containers/containers.conf".
WARN[0000] Failed to decode the keys ["containers.events_logger" "engine.foo"] from "/home/dwalsh/.config/containers/containers.conf".
WARN[0000] Failed to decode the keys ["containers.events_logger" "engine.foo"] from "/home/dwalsh/.config/containers/containers.conf".
WARN[0000] Failed to decode the keys ["containers.events_logger" "engine.foo"] from "/home/dwalsh/.config/containers/containers.conf".
hi

With ~/.config/containers/containers.conf

[containers]
events_logger = "file"
[engine]
foo="bar"

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-06-30 15:17:05 -04:00
Ashley Cui 9fa534c40a Allow /etc/containers/containers.conf to be read by non-root
If a root user writes to a config using Write(), and there is not already an /etc/containers/containers.conf, Write() will create it. This config file also needs to be read by non-root podman.

Signed-off-by: Ashley Cui <acui@redhat.com>
2021-06-22 09:52:09 -04:00
OpenShift Merge Robot 10fc9ceca2 Merge pull request #615 from rhatdan/config
Add support for config drop in directories
2021-06-10 16:44:15 -04:00
Daniel J Walsh 4c51429098 Add support for config drop in directories
Fixes: https://github.com/containers/common/issues/368

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-06-10 16:34:26 -04:00
Tino Rusch 5ec160696b add 'secret' section to the containers.conf struct. 2021-06-10 14:04:32 +02:00
Daniel J Walsh 9c89b403e7 Add default for log-tag
Needed for https://github.com/containers/podman/issues/10204

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-06-09 08:43:07 -04:00
Brent Baude cf1c43959f rootless networking
Set type of rootless networking with:

rootless_networking = "slirp4netns | cni"

slirp is the default

Signed-off-by: Brent Baude <bbaude@redhat.com>
2021-05-20 15:34:44 -05:00
Valentin Rothberg 460874be71 Revert "Do not emit warnings about OCI runtime paths"
This reverts commit 352073be9e as it's
causing a regression as it overwrites any custom OCI runtime with either
rucc, crun or kata.  See the Podman CI failure below:

```
[+0383s] not ok 95 podman build - set runtime
[+0383s] # (from function `die' in file test/system/helpers.bash, line 412,
[+0383s] #  from function `run_podman' in file test/system/helpers.bash, line 220,
[+0383s] #  in test file test/system/070-build.bats, line 70)
```

I currently do not have the time for a proper fix but the next commit
attempting to address the warnings must include tests.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-05-19 13:12:13 +02:00
OpenShift Merge Robot 6b0f9a2be1 Merge pull request #538 from basilgello/fix-9389
Do not emit warnings about OCI runtime paths
2021-05-12 15:05:47 -04:00
OpenShift Merge Robot 73305281fd Merge pull request #541 from ashley-cui/mac
[NO TESTS NEEDED] Fix reading configs on mac and windows
2021-05-11 17:19:52 -04:00
Ashley Cui e237d2da9b Fix reading configs on mac and windows
On Mac and Windows, automtically read default rootless config location, since
unshare.IsRootless doesn't work.

Signed-off-by: Ashley Cui <acui@redhat.com>
2021-05-10 15:27:01 -04:00
Vasyl Gello 352073be9e Do not emit warnings about OCI runtime paths
... before all user configuration files are merged.

This fixes #9389.

Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
2021-05-10 21:39:17 +03:00
OpenShift Merge Robot 4769b30832 Merge pull request #527 from rhatdan/cleanup
Add support for codespell, and fix issues found
2021-05-05 17:09:54 -04:00
Daniel J Walsh dee190ce4c Add support for codespell, and fix issues found
[NO TESTS NEEDED] This is just code cleanup

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-05-05 17:02:11 -04:00
Matthew Heon 85df6670fb Add ability to specify a subnet for the default network
This lays the foundation for c/common to be able to create the
default CNI configuration file itself.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2021-05-04 11:40:22 -04:00
Valentin Rothberg bc6c57edb5 libimage: follow-up changes
The following changes were not split into smaller commits since the
entire package is still work in progress and I want to keep moving:

 * Various small fixes.

 * The internal image cache has been removed as it's a recipe for
   inconsistencies for longer running processes.  This should make
   libimage easier to use for CRI-O and a Podman service.

 * LookupImage now returns storage.ErrUnknownImage rather than nil.
   This simplifies the callers and makes sure we have a consistent
   error.

 * LookupImage is now able to handle manifests lists.  Unless the
   platform is explicitly ignored via the options, the matching
   image within the manifest list is now returned.  This greatly
   simplifies the spec generation in Podman; no callers should have
   to worry about this kind of detail.

 * LookupImage has been refactored into smaller-sized and easier to
   read functions.

 * RemoveImages has been changed to assemble the data of removed or
   untagged images.  This comes in handy for pruning images.  I am
   heavily against having a dedicated API for pruning since the it's
   really just a combination of filtering and removing images which
   RemoveImages already supports.  Hence these changes to satisfy
   the needs of `podman image prune`.
   Furthermore, it now returns an []error slice rather than a single
   error.  Again to make Podman happy which needs to inspect *all*
   errors for setting the appropriate exit code.

 * A rather large refactoring of the removal code along with very
   verbose comments.  Those were largely absent in the Podman code base
   but there many rules and contracts embedded that I partially could
   only reconstruct by manually tests and comparing to Docker.

 * Add a new `containers={true,false}` filter which allows filtering
   images whether they are used by containers (=true) or if no container
   is using them (=false).  This filter is required for pruning images
   in Podman.

 * `libimage/types` has been merged into `libimage`.  Podman has to do
   _a lot of_ massaging for the remote client already and the types
   are pretty much nailed down for the remote API.  Hence, I prefer to
   do some translation between `libimage` types and what Podman needs
   rather than splitting `libimage` in half without an obvious reason.
   This way the package is self-contained allowing for an easier
   navigation and maintenance.

 * `libimage.PullPolicy` has been merged into `pkg/config.PullPolicy`
   to have _one_ central place to deal with pull policies.  The type
   system in `pkg/config` sets "always" as the default unfortunately
   but I think consistency is more important at that point.

 * Added `CopyOptions.DirForceCompress` to enforce layer compression
   when copying to a `dir` destination.

 * We now use `github.com/disiqueira/gotree` for pretty printing image
   trees.  That greatly simplifies the code and we don't have to worry
   about the logic of printing a tree.  Note that trees are now always
   printed top down!

 * Added a new `libimage.ManifestList` type along with an API for local
   lookups and performing certain operations on it to wrap around
   `libimage/manifests` as previously done in `libpod/image` and other
   places in Podman.

 * Correct caching of `(*Image).Inspect`.

 * In addition to username, password and credentials, allow for
   speciying an identity token for copying images.  That's needed for
   Podman's remote API.

 * Make image removal more tolerant toward corrupted images.

 * A new "until=timestamp" filter that can be used by all APIs
   supporting filtering.

 * An empty string now resolves to PullPolicyMissing.

 * `(*Runtime) systemContextCopy()` returns a deep copy of the runtime's
   system context.  Golang's shallow copies are very dangerous for long
   running processes such as Podman's system service.  Hence, we need to
   make sure that base data is not altered over time.  That adds another
   external dependency but I do not see a way around that.  Long term,
   I desire a `(*containers/image/types.SystemContext).Copy()` function.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-05-03 15:20:40 +02:00
Ashley Cui 24f4991dc1 Add support for machine_enabled in containers.conf
machine_enabled is a bool that indicates if Podman is running in a
podman-machine VM

Signed-off-by: Ashley Cui <acui@redhat.com>
2021-04-23 14:37:18 -04:00