Commit Graph

1558 Commits

Author SHA1 Message Date
Debarshi Ray 25ab60d01a build: Bump github.com/NVIDIA/nvidia-container-toolkit to 1.17.6
The src/go.sum file was updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1687
2025-07-21 21:36:42 +02:00
Penn Bauman 1a1b956201 .github/workflows, test/system: Enable 210-ulimit.bats on Ubuntu 22.04
When 'toolbox run ulimit' is invoked, it comes down to invoking
"bash --login -c 'exec ulimit'" inside the container, and it leads to
different outcomes on Fedora and Ubuntu hosts.

On Fedora:
  $ bash --login -c 'exec ulimit'
  unlimited

On Ubuntu:
  $ bash --login -c 'exec ulimit'
  bash: line 1: exec: ulimit: not found

This is because Bash's exec built-in cannot execute another built-in and
needs an external command; and Fedora ships a wrapper for the ulimit
built-in as an external command [1] to satisfy POSIX [2]:
  $ cat /usr/bin/ulimit
  #!/usr/bin/sh
  builtin ulimit "$@"

... that Ubuntu doesn't.

Wrapping the 'ulimit' as 'bash -c ulimit' solves this problem because
then it becomes "bash --login -c 'exec bash -c ulimit'", and the exec
built-in can execute the external command bash(1).

[1] Fedora bash commit 3b09d0d67fe7ff4c
    Fedora bash commit a28ab9933095eaf6
    https://src.fedoraproject.org/rpms/bash/c/3b09d0d67fe7ff4c
    https://src.fedoraproject.org/rpms/bash/c/a28ab9933095eaf6
    https://bugzilla.redhat.com/show_bug.cgi?id=1297166

[2] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/toc.html

https://github.com/containers/toolbox/pull/1599

Signed-off-by: Penn Bauman <me@pennbauman.com>
2025-07-16 15:34:00 +02:00
Debarshi Ray e2fd458335 .github/workflows: Enable 230-cdi.bats on Ubuntu 22.04
Fallout from 6e848b250b

https://github.com/containers/toolbox/pull/1686
2025-07-16 01:53:11 +02:00
Debarshi Ray 62322a9c76 .github/workflows: Bump Go to 1.22 for CI on Ubuntu 22.04
Fallout from eb73692618

https://github.com/containers/toolbox/pull/1685
2025-07-16 00:13:45 +02:00
Debarshi Ray 2099190211 playbooks: Use the same commands as mentioned in the documentation
... at https://containertoolbx.org/install/

This should have been part of commit df22010e4f.

https://github.com/containers/toolbox/pull/1678
2025-07-04 21:34:50 +02:00
Debarshi Ray fb43d3e06e pkg/utils: Remove unused functions
Fallout from d323143c46

https://github.com/containers/toolbox/pull/1677
2025-07-04 21:04:35 +02:00
Debarshi Ray 62712d7589 pkg/utils: Style fixes
Fallout from the following:
  * f5bf741f86
  * 2edc30836b
  * 872eba41a9
  * 8b6418d8aa
  * b166a1f13f
  * 0000cb0151

https://github.com/containers/toolbox/pull/1677
2025-07-04 21:01:19 +02:00
Debarshi Ray cded2709e2 test/system: Remove redundant set-up
There's no need to repeatedly create the home directory and the
containers-storage.conf(5), because their life cycles are suite-wide.
It's enough to create them once as part of the suite-wide set-up hook
(ie., setup_suite()).

It was only necessary to do it this way at a time when Bats < 1.7.0
didn't offer any hooks for suite-wide set-up and tear-down, and the
CONTAINERS_STORAGE_CONF and XDG_RUNTIME_DIR environment variables were
exported to the test cases from the _setup_environment() function.

The switch to using the suite-wide set-up hook offered by Bats >= 1.7.0
in commit 7a387dcc8b removed the need to do this set-up
repeatedly.  Currently, those two environment variables are set globally
outside the _setup_environment() function [1,2], which removes any
lingering doubts about this.

This should have been part of commit 7a387dcc8b.

[1] Commit f4591718e4
    https://github.com/containers/toolbox/commit/f4591718e483bdf5
    https://github.com/containers/toolbox/pull/1672

[2] Commit ad3346f915
    https://github.com/containers/toolbox/commit/ad3346f9153dbf0f
    https://github.com/containers/toolbox/pull/1676

https://github.com/containers/toolbox/pull/1676
2025-07-04 11:37:34 +02:00
Debarshi Ray ad3346f915 test/system: Simplify code by removing a function
It's simpler to check and set all the environment variables in one
place and in the same way, instead of having them scattered and using
different means.

https://github.com/containers/toolbox/pull/1676
2025-07-03 16:25:02 +02:00
dependabot[bot] 0f961c5ac8 build: Bump github.com/go-viper/mapstructure/v2 to 2.3.0
... for GHSA-fv92-fjc5-jj9h.

https://github.com/containers/toolbox/pull/1669
https://github.com/containers/toolbox/security/dependabot/22

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-29 20:41:15 +02:00
Debarshi Ray 009bc14c99 test/system: Restore some configuration paths to their usual values
The default location for a rootless user's storage.conf file [1], which
is overridden by the CONTAINERS_STORAGE_CONF environment variable [2],
is at $XDG_CONFIG_HOME/containers/storage.conf, and the default value of
the rootless_storage_path option is $XDG_DATA_HOME/containers/storage.
Earlier they were being set to different paths because the user's home
directory on the host operating system was not isolated from the system
tests.

Now that the user's home directory is isolated because the system tests
use a custom HOME, these configuration paths can be restored to their
default values relative to this custom HOME.  This will make things more
understandable by making the directory hierarchy within Bats' sandbox
similar to the defaults.

The CONTAINERS_STORAGE_CONF environment variable was not removed to
protect against cases where Bats might get invoked with a different
CONTAINERS_STORAGE_CONF set in the environment.  The other option is to
unset the variable from the environment.  The former was chosen to
deviate as little from the status quo as possible.

[1] https://github.com/containers/storage/blob/main/docs/containers-storage.conf.5.md

[2] https://docs.podman.io/en/latest/markdown/podman.1.html

https://github.com/containers/toolbox/pull/1673
2025-06-29 20:39:32 +02:00
Debarshi Ray 4251a0409f pkg/utils, test/system: Isolate the host's HOME from the system tests
Currently, the test for the 'run' command to ensure that a login shell
is used to invoke commands temporarily changes the user's
~/.bash_profile [1].  This is really inappropriate because the system
tests shouldn't touch the user's configuration or data.

Therefore, it's better to use a custom home directory for the system
tests that's within the sandbox offered by Bats [2].

Some of the common base directories that derive from the user's home
directory [3] were redefined in terms of the custom home directory.
Podman [4,5,6], Toolbx [7] and many other programs rely on these for
various purposes, and Bats might get invoked with different values set
in the environment.  The other option is to unset the variables from the
environment.

This was made possible by commit 3bf9fdde4c that unbroke the
overriding of the HOME environment variable in the Go implementation.
Otherwise, the system tests failed with:
  not ok 8 help: Try unknown command (forwarded to host)
  # (from function `assert_line' in file
      test/system/libs/bats-assert/src/assert.bash, line 488,
  #  in test file test/system/002-help.bats, line 136)
  #   `assert_line --index 0 "Error: unknown command \"foo\" for
      \"toolbox\""' failed
  #
  # -- line differs --
  # index    : 0
  # expected : Error: unknown command "foo" for "toolbox"
  # actual   : Error: crun: chdir to
      `/var/tmp/bats-run-5pDdU0/suite/home`: No such file or
      directory: OCI runtime attempted to invoke a command that was
      not found
  # --
  #

[1] Commit 1ce59a6a2d
    https://github.com/containers/toolbox/commit/1ce59a6a2d3a4c50
    https://github.com/containers/toolbox/pull/1148
    https://github.com/containers/toolbox/issues/1076

[2] https://bats-core.readthedocs.io/en/stable/writing-tests.html

[3] https://specifications.freedesktop.org/basedir-spec/latest/

[4] https://docs.podman.io/en/latest/markdown/podman.1.html

[5] https://github.com/containers/common/blob/main/docs/containers.conf.5.md

[6] https://github.com/containers/storage/blob/main/docs/containers-storage.conf.5.md

[7] https://github.com/containers/toolbox/blob/main/doc/toolbox.conf.5.md

https://github.com/containers/toolbox/pull/1668
2025-06-29 16:52:44 +02:00
Debarshi Ray 01684a72e9 test/system: Simplify code
The "${FOO}" notation for accessing the value of a variable is not
consistently used elsewhere and ShellCheck doesn't insist on it.
Therefore, it's better to use the simpler "$FOO" notation.

https://github.com/containers/toolbox/pull/1672
2025-06-28 02:32:02 +02:00
Debarshi Ray f4591718e4 test/system: Simplify code by removing a variable
The CONTAINERS_STORAGE_CONF environment variable is documented in the
podman(1) manual page [1] and there's no need to have another layer of
indirection by having another variable.

Fallout from 7a5f3ba2e2

[1] https://docs.podman.io/en/latest/markdown/podman.1.html

https://github.com/containers/toolbox/pull/1672
2025-06-28 02:31:52 +02:00
Debarshi Ray cee75ef9f2 test/system: Rename a variable for clarity and better namespacing
Matching the name of the variable with the configuration option improves
clarity, and prefixing the name with TOOLBX prevents it from colliding
with environment variables used by other programs or projects.

https://github.com/containers/toolbox/pull/1672
2025-06-28 02:31:46 +02:00
Debarshi Ray d14d0e52dd test/system: Simplify building an image without a name
https://github.com/containers/toolbox/pull/1671
2025-06-28 01:24:18 +02:00
Debarshi Ray cc5f8fd432 pkg/utils: Preserve HOME environment variable when forwarding to host
Currently, it's impossible to create a Toolbx container with a different
home directory from the host while sitting inside a Toolbx container.

Preserving the HOME environment variable when forwarding to the host
will enable users to create containers with different home directories
for increased isolation while sitting inside a Toolbx container, and to
isolate the host's HOME from the system tests.

This was never supported by the POSIX shell implementation.

https://github.com/containers/toolbox/issues/1044
https://github.com/containers/toolbox/issues/1564
2025-06-27 21:22:49 +02:00
Debarshi Ray 3bf9fdde4c cmd/create, cmd/run, cmd/utils: Unbreak overriding the HOME variable
The POSIX shell implementation used to read and respect the HOME
environment variable.  It broke when the Go implementation started using
user.Current() [1], because it uses getpwuid_r(3), which only uses the
GNU Name Service Switch's (or NSS') password database and ignores HOME.

This created a strange situation where the toolbox(1) binary ignored the
HOME environment variable, while the profile.d/toolbox.sh shell start-up
snippet and Podman read and respected it.

Restoring the HOME environment variable will enable users to create
Toolbx containers with different home directories from the host for
increased isolation, and to isolate the host's HOME from the system
tests.

Fallout from e8d7f25e83

[1] https://pkg.go.dev/os/user#Current

https://github.com/containers/toolbox/issues/1044
https://github.com/containers/toolbox/issues/1564
2025-06-26 21:04:34 +02:00
Debarshi Ray eb73692618 build, pkg/nvidia: Bump NVIDIA Container Toolkit to 1.17.5
NVIDIA Container Toolkit 1.17.5 requires Go >= 1.22 [1], and starts
using enable-cuda-compat hooks in the Container Device Interface
specification generated by it [2].  For example:
  "hookName": "createContainer",
  "path": "/usr/bin/nvidia-cdi-hook",
  "args": [
    "nvidia-cdi-hook",
    "enable-cuda-compat",
    "--host-driver-version=570.153.02"
  ]

The new hook makes it possible to have containers with a
/usr/local/cuda/compat/libcuda.so.* that's newer than the proprietary
NVIDIA driver on the host operating system, so that applications can use
a newer CUDA without having to update the driver [3].  Even though this
sounds useful, the hook has been disabled until it's handled by the
'init-container' command and there's a clear way to test it.

The src/go.sum file was updated with 'go mod tidy'.

[1] NVIDIA Container Toolkit commit 5bdf14b1e7c24763
    https://github.com/NVIDIA/nvidia-container-toolkit/commit/5bdf14b1e7c24763
    https://github.com/NVIDIA/nvidia-container-toolkit/pull/941
    https://github.com/NVIDIA/nvidia-container-toolkit/pull/950

[2] NVIDIA Container Toolkit commit 76040ff2ad63fb82
    https://github.com/NVIDIA/nvidia-container-toolkit/commit/76040ff2ad63fb82
    https://github.com/NVIDIA/nvidia-container-toolkit/pull/906
    https://github.com/NVIDIA/nvidia-container-toolkit/pull/948

[3] https://docs.nvidia.com/deploy/cuda-compatibility/

https://github.com/containers/toolbox/pull/1662
2025-06-11 21:30:11 +02:00
Debarshi Ray a49f70effe build: Bump tags.cncf.io/container-device-interface to 0.8.1
The indirect dependencies in the src/go.mod file, and the src/go.sum
file were updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1662
2025-06-11 15:22:06 +02:00
Debarshi Ray 40e3c5a63f Prepare 0.1.2
https://github.com/containers/toolbox/pull/1653
2025-06-03 22:08:50 +02:00
Debarshi Ray 231904e5ad build: Unbreak 'go build' by using micro version in go.mod's go line
Currently, 'go build' is failing on Fedora 42 Workstation:
  $ meson compile -C builddir --verbose
  ...
  /path/src/go-build-wrapper /path/src /path/builddir src/toolbox 0.1.1
      cc /lib64/ld-linux-x86-64.so.2 false
  go: updates to go.mod needed; to update it:
          go mod tidy
  ninja: build stopped: subcommand failed.

... with Go version:
  $ go version
  go version go1.24.3 linux/amd64
  $ rpm -q golang
  golang-1.24.3-2.fc42.x86_64

Strangely, the CI hasn't been failing on Fedora 42 with the same Go
version [1].

Starting from Go version 1.21.0, Go started using an explicit 0 micro
version instead of skipping it - compare Go 1.20 and 1.21.0 [2].  It
looks like recent versions of Go are pedantic about using the exact
version number.

[1] https://github.com/containers/toolbox/pull/1657

[2] https://github.com/golang/go/releases/tag/go1.20
    https://github.com/golang/go/releases/tag/go1.21.0

https://github.com/containers/toolbox/pull/1659
2025-06-03 22:07:00 +02:00
Debarshi Ray 9ac6728597 build: Bump github.com/spf13/viper to 1.20.1
The src/go.sum file was updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1656
2025-06-02 22:34:17 +02:00
Debarshi Ray 7ee347278e .github, build, playbooks: Bump github.com/spf13/viper to 1.20.0
... to reduce the number of indirect dependencies [1].

The indirect dependencies in the src/go.mod file, and the src/go.sum
file were updated with 'go mod tidy'.

This reverts commit 8b62d7e95d because the
go.opencensus.io dependency was removed from github.com/spf13/viper in
version 1.20.0 [1].

[1] Viper commit 7ad8e1ea014790e2
    https://github.com/spf13/viper/commit/7ad8e1ea014790e2
    https://github.com/spf13/viper/pull/1860
    https://github.com/spf13/viper/issues/1845

https://github.com/containers/toolbox/pull/1657
2025-06-02 22:33:30 +02:00
Debarshi Ray a0314d88fe build: Bump golang.org/x/sys to 0.29.0
The src/go.sum file was updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1656
2025-06-02 22:30:22 +02:00
Debarshi Ray 740e92cf7b build: Bump golang.org/x/sys to 0.28.0
The src/go.sum file was updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1656
2025-06-02 22:30:18 +02:00
Debarshi Ray 858916cae4 build: Bump golang.org/x/sys to 0.27.0
The src/go.sum file was updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1656
2025-06-02 22:30:16 +02:00
Debarshi Ray 2333edfac5 build: Bump github.com/fsnotify/fsnotify to 1.8.0
The src/go.sum file was updated with 'go mod tidy'.

https://github.com/containers/toolbox/pull/1655
2025-06-02 19:48:33 +02:00
Debarshi Ray 5ed2442214 Give access to the CA certificates from the host
This uses the same approach taken by Flatpak [1] to ensure that the
certificates from certificate authorities (or CAs) that are available
inside a Toolbx container are kept synchronized with the host operating
system.  Any program that uses PKCS #11 to access CA certificates should
see the same ones both inside the container and on the host.

During every 'enter' and 'run' command, toolbox(1) ensures that an
instance of 'p11-kit server' is running on the host listening on a local
file system socket that's accessible to both the container and the host.
If an instance is already running, then a second one is not created.
The location of the socket is injected into the container through the
P11_KIT_SERVER_ADDRESS environment variable.

Just like Flatpak, the singleton 'p11-kit server' process is not
terminated when the last 'enter' or 'run' command exits.

The Toolbx container's entry point configures it to use the
p11-kit-client.so PKCS #11 module instead of the usual p11-kit-trust.so
module.  This talks to the 'p11-kit server' instance running on the host
over the socket instead of reading the CA certificates that are present
inside the container.

However, unlike Flatpak, this doesn't use D-Bus to set up the
communication between the container and the host, because when invoked
as 'sudo toolbox ...' there's no user or session D-Bus instance
available for the root user.

This set-up is skipped if 'p11-kit server' can't be run on the host, or
if the /etc/pkcs11/modules directory for configuring PKCS #11 modules or
p11-kit-client.so are missing inside the container.  None of these are
considered hard dependencies to accommodate size-constrained OSes like
Fedora CoreOS that might not have 'p11-kit server', and existing Toolbx
containers and old images that might not have p11-kit-client.so.

The UBI-based toolbox images haven't yet been updated to contain
p11-kit-client.so.  Until that happens, containers created from them
won't have access to the CA certificates from the host.

The CI needs to be run without 'p11-kit server' because the lingering
singleton process causes Bats to hang when tearing down the suite of
system tests [2].  To terminate the 'p11-kit server' instance run by the
system tests, it needs to be distinguishable from the instance run by
'normal' use of Toolbx by the user.  One way to do this is to isolate
the host operating system's XDG_RUNTIME_DIR from the system tests.
Unfortunately, this is easier said than done [3].  So, this workaround
has to suffice until the problem is solved.

On the Ubuntu 22.04 CI nodes, it's not possible to remove the p11-kit
package that provides 'p11-kit server', because it leads to:
  $ sudo dpkg --purge p11-kit
  dpkg: dependency problems prevent removal of p11-kit:
   adoptium-ca-certificates depends on p11-kit.

Therefore, as a workaround only the /usr/libexec/p11-kit/p11-kit-server
binary that provides the 'server' command is removed.  The rest of the
p11-kit package is left untouched.

[1] Flatpak commit 66b2ff40f7caf3a7
    https://github.com/flatpak/flatpak/commit/66b2ff40f7caf3a7
    https://github.com/flatpak/flatpak/pull/1757
    https://github.com/p11-glue/p11-kit/issues/68

[2] https://bats-core.readthedocs.io/en/stable/writing-tests.html

[3] https://github.com/containers/toolbox/pull/1652

https://github.com/containers/toolbox/issues/626
2025-06-02 15:58:46 +02:00
Debarshi Ray 9e776b6c94 pkg/utils: Add a function to check if p11-kit-client.so is present
A subsequent commit will use this to give Toolbx containers access to
the certificates from certificate authorities on the host.

The ideal goal is to ensure that all supported Toolbx containers and
images have p11-kit-client.so in them.  In practice, some of them never
will.  Either because it's an existing container or an older version of
an image that was already present in the local containers/storage image
store, or because the operating system is too old.

Therefore, there needs to be a way to check at runtime if a Toolbx
container has p11-kit-client.so or not.

https://github.com/containers/toolbox/issues/626
2025-06-01 15:26:01 +02:00
Debarshi Ray 456f37794d cmd/root, pkg/utils: Split out the code to acquire a file lock
A subsequent commit will use this to give Toolbx containers access to
the certificates from certificate authorities on the host.

This changes the user-visible error message from:
  $ toolbox --verbose list
  ...
  DEBU Migrating to newer Podman: failed to create migration lock file
      /run/user/1000/toolbox/migrate.lock: open
      /run/user/1000/toolbox/migrate.lock: no such file or directory
  Error: failed to create migration lock file

... to:
  $ toolbox --verbose list
  ...
  DEBU Migrating to newer Podman: failed to create lock file
      /run/user/1000/toolbox/migrate.lock: open
      /run/user/1000/toolbox/migrate.lock: no such file or directory
  Error: failed to create lock file

Or, from:
  $ toolbox --verbose list
  ...
  DEBU Migrating to newer Podman: failed to acquire migration lock on
      /run/user/1000/toolbox/migrate.lock: bad file descriptor
  Error: failed to acquire migration lock

... to:
  $ toolbox --verbose list
  ...
  DEBU Migrating to newer Podman: failed to acquire lock on
      /run/user/1000/toolbox/migrate.lock: bad file descriptor
  Error: failed to acquire lock

This is admittedly less specific without the debug logs, but it's
probably alright because it's such an unlikely error.

https://github.com/containers/toolbox/issues/626
2025-06-01 15:26:01 +02:00
Debarshi Ray b7be82d51e pkg/utils: Update fallback release to 42 for non-fedora hosts
Fedora 40 reached End of Life on 13th May 2025:
https://docs.fedoraproject.org/en-US/releases/eol/

https://github.com/containers/toolbox/pull/1651
2025-05-30 15:07:17 +02:00
Debarshi Ray 7cfe9a7f18 .zuul: Drop testing on Fedora 40
Fedora 40 reached End of Life on 13th May 2025:
https://docs.fedoraproject.org/en-US/releases/eol/

https://github.com/containers/toolbox/pull/1650
2025-05-29 23:44:56 +02:00
Jens Petersen 88a08351b2 .github/workflows, images/ubuntu: Add image definition for Ubuntu 25.04
https://github.com/containers/toolbox/pull/1638

Signed-off-by: Jens Petersen <petersen@redhat.com>
2025-05-29 23:22:43 +02:00
Debarshi Ray 836c0557f4 test/system: Optimize the environment variable tests
The system tests can be very I/O intensive, because many of them copy
OCI images from the test suite's image cache directory to its local
container/storage store, create containers, and then delete everything
to run the next test with a clean slate.  This makes them slow.

The runtime environment tests, which includes the environment variable
tests, are particularly slow because they don't skip the I/O even when
testing error handling.  This makes them a good target for
optimizations.

The environment variable tests query the values of different environment
variables from different containers without changing their state.
Therefore, a lot of disk I/O can be avoided by creating these containers
only once for all the tests.

This can reduce the time needed to run the environment variable tests
from almost 26 minutes to almost 9 minutes.

https://github.com/containers/toolbox/pull/1646
2025-05-12 23:26:00 +02:00
Debarshi Ray a5a0d5350f test/system: Remove redundant clean-up
The IMAGE_CACHE_DIR environment variable is defined as
"${BATS_SUITE_TMPDIR}/image-cache" [1].  Earlier, it used to be
"${BATS_RUN_TMPDIR}/image-cache".

There's no need to clean up anything inside BATS_RUN_TMPDIR or
BATS_SUITE_TMPDIR after the test suite has finished running, because
their life cycle is managed by Bats [2].

[1] Commit 3a549a6252
    https://github.com/containers/toolbox/commit/3a549a6252e990d6
    https://github.com/containers/toolbox/pull/1452

[2] https://bats-core.readthedocs.io/en/stable/writing-tests.html

Fallout from 9820550c82

https://github.com/containers/toolbox/pull/1645
2025-05-12 17:58:15 +02:00
Debarshi Ray d64682af0d test/system: Don't use XDG_CACHE_HOME or HOME for temporary files
The XDG_CACHE_HOME environment variable is supposed to default to
$HOME/.cache [1], just as it did in the test suite, and this location is
meant to be used as a cache for 'normal' use by the user.  Test suites
generally don't qualify as 'normal' use.

One expects that deleting the cache shouldn't affect 'normal' use other
than degrading performance.  However, deleting these temporary files
used by the test suite will cause actual breakage.  Even if the user
doesn't manually delete the cache, two concurrent invocations of the
test suite can do so or lead to other unexpected collisions, because the
paths are constant across multiple invocations.

Therefore, it's better to limit the scope of the test suite's temporary
files within the sandbox offered by Bats [2].  The sandbox is clearly
labelled as being used by Bats, is unique for each invocation, and Bats
takes care of cleaning everything up once it has finished running.

Note that there's no need for the system-test-storage sub-directory
under BATS_SUITE_TMPDIR.  So it was left out.

[1] https://specifications.freedesktop.org/basedir-spec/latest/

[2] https://bats-core.readthedocs.io/en/stable/writing-tests.html

https://github.com/containers/toolbox/pull/1645
2025-05-12 17:41:52 +02:00
Debarshi Ray e98032352e images/ubuntu: Create the directory for configuring PKCS#11 modules
The p11-kit-modules package in Ubuntu provides p11-kit-client.so, but
the /etc/pkcs11/modules directory that's necessary to configure p11-kit
to use p11-kit-client.so is not created by any package.

It's better to ensure that the /etc/pkcs11/modules directory exists in
the image, instead of having the Toolbx container's entry point create
it at runtime, because it can be a confirmation that p11-kit was built
to read the module configuration from this location.

This should have been part of commit aa8507730d.

https://github.com/containers/toolbox/issues/626
2025-05-07 19:03:18 +02:00
Debarshi Ray 26b3314fa5 images/arch: Create the directory for configuring PKCS#11 modules
The /etc/pkcs11 directory and /etc/pkcs11/pkcs11.conf.example file are
created by the p11-kit package in Arch Linux, and the lib11-kit package
provides p11-kit-client.so.  However, the /etc/pkcs11/modules directory
that's necessary to configure p11-kit to use p11-kit-client.so is not
created by any package.

It's better to ensure that the /etc/pkcs11/modules directory exists in
the image, instead of having the Toolbx container's entry point create
it at runtime, because it can be a confirmation that p11-kit was built
to read the module configuration from this location.

This should have been part of commit 259de86c8f.

https://github.com/containers/toolbox/issues/626
2025-05-07 17:43:29 +02:00
Debarshi Ray f0a7304e75 pkg/utils: Mark a private function as such and drop one that's unused
It's been a while since it's been necessary to read the ID field from
os-release(5) outside this package or the VARIANT_ID field anywhere at
all.  Therefore, it's time to adjust the code to reflect this reality.

Fallout from 8caa7cd828

https://github.com/containers/toolbox/pull/1642
2025-05-07 01:50:25 +02:00
Debarshi Ray 5881bc43f3 test/system: Optimize the D-Bus tests
The system tests can be very I/O intensive, because many of them copy
OCI images from the test suite's image cache directory to its local
container/storage store, create containers, and then delete everything
to run the next test with a clean slate.  This makes them slow.

The runtime environment tests, which includes the D-Bus tests, are
particularly slow because they don't skip the I/O even when testing
error handling.  This makes them a good target for optimizations.

The D-Bus tests check if methods can be called across the user or
session and system D-Bus instances from different containers without
changing their state.  Therefore, a lot of disk I/O can be avoided by
reating these containers only once for all the tests.

This can reduce the time needed to run the D-Bus tests from almost 10
minutes to almost 5 minutes.

https://github.com/containers/toolbox/pull/1641
2025-05-06 23:16:27 +02:00
Debarshi Ray 7a413e66b9 Move the code for Ubuntu support into its own file
This will reduce the size of the src/pkg/utils/utils.go file and make it
easier to specify which part of the code base is maintained by whom.

https://github.com/containers/toolbox/pull/1639
2025-05-06 02:39:28 +02:00
Debarshi Ray c794e183da Move the code for Red Hat Enterprise Linux support into its own file
This will reduce the size of the src/pkg/utils/utils.go file and make it
easier to specify which part of the code base is maintained by whom.

https://github.com/containers/toolbox/pull/1639
2025-05-06 02:20:18 +02:00
Debarshi Ray ab76cbca67 Move the code for Fedora support into its own file
This will reduce the size of the src/pkg/utils/utils.go file and make it
easier to specify which part of the code base is maintained by whom.

https://github.com/containers/toolbox/pull/1639
2025-05-06 02:07:17 +02:00
Debarshi Ray f9ebd5195b Move the code for Arch Linux support into its own file
This will reduce the size of the src/pkg/utils/utils.go file and make it
easier to specify which part of the code base is maintained by whom.

https://github.com/containers/toolbox/pull/1639
2025-05-06 01:56:01 +02:00
Debarshi Ray 1b9dd007ea test/system: Optimize the networking tests
The system tests can be very I/O intensive, because many of them copy
OCI images from the test suite's image cache directory to its local
container/storage store, create containers, and then delete everything
to run the next test with a clean slate.  This makes them slow.

The runtime environment tests, which includes the networking tests, are
particularly slow because they don't skip the I/O even when testing
error handling.  This makes them a good target for optimizations.

The networking tests check the behaviour and configuration of the
network in different containers without changing their state.
Therefore, a lot of disk I/O can be avoided by creating these containers
only once for all the tests.

This can reduce the time needed to run the networking tests from almost
15 minutes to almost 6 minutes.

https://github.com/containers/toolbox/pull/1637
2025-05-01 23:28:17 +02:00
Debarshi Ray 259de86c8f images/arch: Avoid losing p11-kit-client.so by accident
The libp11-kit package was added to the arch-toolbox image to ensure the
presence of p11-kit-client.so.  Currently, the package is already pulled
in by various dependencies, like the gnutls and p11-kit packages.
Therefore, it doesn't increase the size of the base image, but serves as
a safeguard against any inadvertent changes.

A subsequent commit will use this to give Toolbx containers access to
the certificates from certificate authorities on the host.  This commit
was kept separate from the changes to toolbox(1) to ensure that the
arch-toolbox image is ready before that happens.

https://github.com/containers/toolbox/issues/626
2025-05-01 20:37:18 +02:00
Debarshi Ray aa8507730d .github/workflows, images/ubuntu: Add p11-kit-client.so to newer Ubuntus
A subsequent commit will use this to give Toolbx containers access to
the certificates from certificate authorities on the host.  This commit
was kept separate from the changes to toolbox(1) to ensure that the
ubuntu-toolbox images are ready before that happens.

Unfortunately, Ubuntu 16.04 Xenial Xerus has p11-kit 0.23.2 [1], while
p11-kit-client.so was introduced in p11-kit 0.23.10 [2].  Therefore,
this feature will be disabled for Ubuntu 16.04.

This reverts parts of commit 1e9308625a to
re-enable building the ubuntu-toolbox:18.04 image.

[1] https://code.launchpad.net/~git-ubuntu-import/ubuntu/+source/p11-kit/+git/p11-kit/+ref/ubuntu/xenial-updates

[2] p11-kit commit 0684cd7b7f815b41
    https://github.com/p11-glue/p11-kit/commit/0684cd7b7f815b41
    https://github.com/p11-glue/p11-kit/pull/15

https://github.com/containers/toolbox/issues/626
2025-05-01 20:29:12 +02:00
Debarshi Ray 02fe08f70e cmd/initContainer: Style fix
Use a strings.Builder [1] instance instead of raw string literals for
consistency.

Fallout from 772b66bf3e

[1] https://pkg.go.dev/strings#Builder

https://github.com/containers/toolbox/pull/1636
2025-05-01 20:28:04 +02:00
Debarshi Ray 3017a46c03 test/system: Optimize the group and user tests
The system tests can be very I/O intensive, because many of them copy
OCI images from the test suite's image cache directory to its local
container/storage store, create containers, and then delete everything
to run the next test with a clean slate.  This makes them slow.

The runtime environment tests, which includes the group and user tests,
are particularly slow because they don't skip the I/O even when testing
error handling.  This makes them a good target for optimizations.

The group and user tests check the group and user configuration in
different containers without changing their state.  Therefore, a lot of
disk I/O can be avoided by creating these containers only once for all
the tests.

This can reduce the time needed to run the group and user tests from
almost 22 minutes to almost 5 minutes.

https://github.com/containers/toolbox/pull/1635
2025-05-01 20:24:07 +02:00