Commit Graph

125 Commits

Author SHA1 Message Date
Valentin Rothberg cd2797eb34 pkg/config: use NewSlice, Get and Set where possible
To improve the code and reduce memory allocations.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 10:04:20 +02:00
Valentin Rothberg e212082542 pkg/config: turn machine Volumes into attributedstring.Slice
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 09:17:22 +02:00
Valentin Rothberg 5fb9ed7f84 pkg/config: turn NetavarkPluginDirs into attributedstring.Slice
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 09:17:22 +02:00
Valentin Rothberg 67a73c7cc6 pkg/config: turn CNIPluginDirs into attributedstring.Slice
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 09:17:22 +02:00
Valentin Rothberg 89b8572671 pkg/config: turn AddCompression into attributedstring.Slice
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 09:17:22 +02:00
Valentin Rothberg cad0135389 pkg/config: turn NetworkCmdOptions into attributedstring.Slice
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 09:17:22 +02:00
Valentin Rothberg 8a06b6cb94 pkg/config: turn HelperBinariesDir into attributedstring.Slice
Also tag it as omitempty to fix the test.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 09:17:22 +02:00
Valentin Rothberg 12bde4bc00 pkg/config: turn Capabilities into attributedstring.Slice
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 09:17:22 +02:00
Valentin Rothberg bde9e751dc pkg/config: turn CgroupConf into attributedstring.Slice
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 09:17:22 +02:00
Valentin Rothberg b8c3014c2a pkg/config: turn devices into attributedstring.Slice
The tests are messy and should be turned into table-driven tests but I
do not have time at the moment.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 09:17:22 +02:00
Valentin Rothberg b103cb9e93 containers.conf: appendable string arrays, Part 1
Commit 395ba05c44 implemented a POC to allow for changing the behavior
when loading multiple container.conf files in sequence.  By default, the
TOML encoder will override existing data/fields with the one specified
in the loaded file.  The POC has demonstrated how this behavior can be
changed to append string slices instead of overriding/replacing them
entirely.

This change is the first step of integrating these appendable string
arrays into containers.conf and starts with enabling the `Env`,
`Mounts`, and `Volumes` fields in the `[Containers]` table.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-24 11:47:46 +02:00
Paul Holzinger 6a79383d51 pkg/config: use empty default for db_backend
Podman should default to sqlite for new installs, however to not break
upgrades we should detect if a boltdb database exists and use that in
such case. Now in order to distinguish between an explicitly set
"sqlite" and "boltdb" and nothing set we use an empty default.

With that podman can know if we really should use the default or if it
was configured for a db explicitly. The actual detection logic must be
implemented in podman as we only know the file locations there.

This commit also drops the unused StateType as this was not used at all.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-10 15:57:52 +02:00
Valentin Rothberg ac851d5930 containers.conf: add `privileged` field to containers table
As requested in containers/podman/issues/20000, add a `privileged` field
to the containers table in containers.conf.  I was hesitant to add such
a field at first (for security reasons) but I understand that such a
field can come in handy when using modules - certain workloads require a
privileged container.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-05 13:22:35 +02:00
Chetan Giradkar 819434a2ea Remove ActiveDestination method to move into podman
The method ActiveDestination was being used only by Podman and there seemed to code complications as the code is split in multiple parts. Hence, moved the code to Podman to make it more readable and efficient.

Signed-off-by: Chetan Giradkar <cgiradka@redhat.com>
2023-09-20 13:29:52 +01:00
Aditya R 359ff162d0 containers.conf: add field for AddCompression to Engine table
Allows users to set default value of `AddCompression` to Engine table so
users can use https://github.com/containers/buildah/pull/4912 by
default.

Closes: https://github.com/containers/buildah/pull/4912#issuecomment-1661105029

Signed-off-by: Aditya R <arajan@redhat.com>
2023-08-24 17:10:06 +05:30
Valentin Rothberg 961863eab1 pkg/config: tests: do not load default config before each test
It's wasteful and `sut` was not a name I would now understand. Change
the tests that need a default config.  The diff also shows that the
tests would benefit a lot from a rewrite into a table-driven form but I
do not want to shave the entire Yak.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-08-14 09:40:27 +02:00
Valentin Rothberg e00d7e3560 pkg/config: unexport DefaultConfig
It has no external user and should not be exported to avoid any API
misuse; built-in defaults are an implementation detail.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-08-14 09:40:27 +02:00
OpenShift Merge Robot 8694484524 Merge pull request #1586 from umohnani8/farms
Add Farms to config
2023-08-05 04:34:23 +02:00
Urvashi Mohnani a489f0261c Update system connection to add to farm
A new --farm flag is being added to podman system connection
add so that when a new connection is added it can be added to a new
or existing farm. Update the code here to be able to do that.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-08-03 09:53:55 -04:00
Urvashi Mohnani 42a36d1ba1 Add Farms TOML table
Add two new fields Farms and DefaultFarm to the Config
to be used by the new podman buildfarm command.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-08-03 09:53:48 -04:00
Daniel J Walsh cdb801ec18 We don't want TERM environment turned on by default
This should only be done in container-engines that are using a
terminal.

Reverts: https://github.com/containers/common/pull/267

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-07-31 11:33:28 -04:00
Daniel J Walsh 19a6a187a9 Allow mounts to be specified in containers.conf
We want to allow HPC Customers and others to specify mounts
inside of containers.conf, so that they can have a default
list of mounts into all of thier containers.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-07-25 15:06:08 -04:00
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
Doug Rabson 5daab4a8cf pkg/config: override DefaultInitPath for FreeBSD
FreeBSD packages typically install files under /usr/local on FreeBSD.

Signed-off-by: Doug Rabson <dfr@rabson.org>
2023-06-12 16:00:37 +01:00
Doug Rabson d68f132c74 pkg/config: fix unit tests for FreeBSD
This just disables the capabilities test - everything else already
passed.

Signed-off-by: Doug Rabson <dfr@rabson.org>
2023-06-12 15:11:50 +01:00
Daniel J Walsh a370cfad72 Add some fixes for CompressionFormat
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-05-30 17:32:27 -04: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
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 386adadc84 Add kube_generate_type defaults
Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-04-03 18:12:37 -04: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
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 00eae8d87d Back by popular demand CAP_SYS_CHROOT
We are getting a lot of issues on our removal of CAP_SYS_CHROOT
from the default list of capabilities used by Podman, so adding
it back until we do a major release.

This capabilty is also needed to successfully run the
quay.io/buildah/stable image with Podman.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-03-21 10:25:29 -04: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
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
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
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
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
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
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
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
Dominique Martinet 837a035e34 pkgs/config tests: fix tests when /usr/libexec/foo does not exist
cni_plugin_dirs validation require directories to exist, use a
directory that is more likely to exist like /tmp instead of an
arbitrary path that won't exist on most systems

Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
2022-07-08 08:07:37 +09: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
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
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