diff --git a/.github/workflows/ubuntu-tests.yaml b/.github/workflows/ubuntu-tests.yaml index 35526be77..71a96c3f7 100644 --- a/.github/workflows/ubuntu-tests.yaml +++ b/.github/workflows/ubuntu-tests.yaml @@ -41,6 +41,7 @@ jobs: apache2-utils \ bash-completion \ codespell \ + dbus \ fish \ flatpak \ gcc \ diff --git a/meson.build b/meson.build index 8f0986b8d..d97730cd6 100644 --- a/meson.build +++ b/meson.build @@ -21,6 +21,7 @@ go_md2man = find_program('go-md2man') bats = find_program('bats', required: false) codespell = find_program('codespell', required: false) +dbus_daemon = find_program('dbus-daemon', required: false) htpasswd = find_program('htpasswd', required: false) openssl = find_program('openssl', required: false) diff --git a/playbooks/dependencies-centos-9-stream.yaml b/playbooks/dependencies-centos-9-stream.yaml index 1c6dd3c18..f06858629 100644 --- a/playbooks/dependencies-centos-9-stream.yaml +++ b/playbooks/dependencies-centos-9-stream.yaml @@ -2,6 +2,7 @@ become: yes package: name: + - dbus-daemon - flatpak-session-helper - gcc - golang @@ -61,7 +62,7 @@ chdir: '{{ zuul.project.src_dir }}' - name: Check versions of crucial packages - command: rpm -qa ShellCheck bash bash-completion bats codespell *kernel* gcc *glibc* golang golang-github-cpuguy83-md2man shadow-utils-subid-devel podman conmon containernetworking-plugins containers-common container-selinux crun fuse-overlayfs flatpak-session-helper skopeo + command: rpm -qa ShellCheck bash bash-completion bats codespell dbus-daemon *kernel* gcc *glibc* golang golang-github-cpuguy83-md2man shadow-utils-subid-devel podman conmon containernetworking-plugins containers-common container-selinux crun fuse-overlayfs flatpak-session-helper skopeo - name: Show podman versions command: podman version diff --git a/playbooks/dependencies-fedora-restricted.yaml b/playbooks/dependencies-fedora-restricted.yaml index 4456941df..4a7d62b76 100644 --- a/playbooks/dependencies-fedora-restricted.yaml +++ b/playbooks/dependencies-fedora-restricted.yaml @@ -47,6 +47,15 @@ update_cache: "{{ true if zuul.attempts > 1 else false }}" use: "{{ 'dnf' if zuul.attempts > 1 else 'auto' }}" +- name: Ensure that dbus-daemon(1) is absent + become: yes + package: + name: + - dbus-daemon + state: absent + update_cache: "{{ true if zuul.attempts > 1 else false }}" + use: "{{ 'dnf' if zuul.attempts > 1 else 'auto' }}" + - name: Ensure that 'p11-kit server' is absent become: yes package: diff --git a/playbooks/dependencies-fedora.yaml b/playbooks/dependencies-fedora.yaml index 9e542f537..59915ae94 100644 --- a/playbooks/dependencies-fedora.yaml +++ b/playbooks/dependencies-fedora.yaml @@ -22,6 +22,7 @@ - ShellCheck - bats - codespell + - dbus-daemon - fish - flatpak-session-helper - gcc @@ -64,7 +65,7 @@ chdir: '{{ zuul.project.src_dir }}' - name: Check versions of crucial packages - command: rpm -qa ShellCheck bash bash-completion bats codespell *kernel* gcc *glibc* shadow-utils-subid-devel golang golang-github-cpuguy83-md2man podman conmon containernetworking-plugins containers-common container-selinux crun fuse-overlayfs flatpak-session-helper skopeo + command: rpm -qa ShellCheck bash bash-completion bats codespell dbus-daemon *kernel* gcc *glibc* shadow-utils-subid-devel golang golang-github-cpuguy83-md2man podman conmon containernetworking-plugins containers-common container-selinux crun fuse-overlayfs flatpak-session-helper skopeo - name: Show podman versions command: podman version diff --git a/playbooks/setup-env-migration-path-for-coreos-toolbox.yaml b/playbooks/setup-env-migration-path-for-coreos-toolbox.yaml index 6fe33129e..3fad2fb0d 100644 --- a/playbooks/setup-env-migration-path-for-coreos-toolbox.yaml +++ b/playbooks/setup-env-migration-path-for-coreos-toolbox.yaml @@ -1,5 +1,5 @@ # -# Copyright © 2022 – 2024 Red Hat, Inc. +# Copyright © 2022 – 2025 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,6 +20,6 @@ - include_tasks: dependencies-centos-9-stream.yaml - name: Set up build directory - command: meson -Dmigration_path_for_coreos_toolbox=true builddir + command: meson setup -Dmigration_path_for_coreos_toolbox=true builddir args: chdir: '{{ zuul.project.src_dir }}' diff --git a/src/pkg/utils/utils.go b/src/pkg/utils/utils.go index e914f292c..a80cea436 100644 --- a/src/pkg/utils/utils.go +++ b/src/pkg/utils/utils.go @@ -295,7 +295,6 @@ func ForwardToHost() (int, error) { // https://github.com/containers/libpod/tree/master/pkg/cgroups func GetCgroupsVersion() (int, error) { var st syscall.Statfs_t - if err := syscall.Statfs("/sys/fs/cgroup", &st); err != nil { return -1, err } @@ -474,40 +473,6 @@ func GetInitializedStamp(entryPointPID int, targetUser *user.User) (string, erro return initializedStamp, nil } -// GetMountPoint returns the mount point of a target. -func GetMountPoint(target string) (string, error) { - var stdout strings.Builder - - if err := shell.Run("df", nil, &stdout, nil, "--output=target", target); err != nil { - return "", err - } - - output := stdout.String() - options := strings.Split(output, "\n") - if len(options) != 3 { - return "", errors.New("unexpected output from df(1)") - } - - mountPoint := strings.TrimSpace(options[1]) - return mountPoint, nil -} - -// GetMountOptions returns the mount options of a target. -func GetMountOptions(target string) (string, error) { - var stdout strings.Builder - findMntArgs := []string{"--noheadings", "--output", "OPTIONS", target} - - if err := shell.Run("findmnt", nil, &stdout, nil, findMntArgs...); err != nil { - return "", err - } - - output := stdout.String() - options := strings.Split(output, "\n") - - mountOptions := strings.TrimSpace(options[0]) - return mountOptions, nil -} - func GetP11KitServerSocket(targetUser *user.User) (string, error) { toolbxRuntimeDirectory, err := GetRuntimeDirectory(targetUser) if err != nil { @@ -579,6 +544,7 @@ func GetSupportedDistros() []string { for d := range supportedDistros { distros = append(distros, d) } + return distros } @@ -596,12 +562,12 @@ func ImageReferenceCanBeID(image string) bool { if err != nil { panic("regular expression for ID reference matching is invalid") } + return matched } func ImageReferenceGetBasename(image string) string { var i int - if ImageReferenceHasDomain(image) { i = strings.IndexRune(image, '/') } @@ -629,7 +595,6 @@ func ImageReferenceGetDomain(image string) string { func ImageReferenceGetTag(image string) string { var i int - if ImageReferenceHasDomain(image) { i = strings.IndexRune(image, '/') } diff --git a/test/system/203-network.bats b/test/system/203-network.bats index bcba97596..13c23c94a 100644 --- a/test/system/203-network.bats +++ b/test/system/203-network.bats @@ -35,7 +35,7 @@ readonly RESOLVER_SH='resolvectl --legend false --no-pager --type "$0" query "$1 setup_file() { bats_require_minimum_version 1.10.0 - cleanup_all + # cleanup_all pushd "$HOME" || return 1 if echo "$TOOLBX_TEST_SYSTEM_TAGS" | grep "arch" >/dev/null 2>/dev/null; then diff --git a/test/system/config/containers.conf b/test/system/config/containers.conf new file mode 100644 index 000000000..17431c9b7 --- /dev/null +++ b/test/system/config/containers.conf @@ -0,0 +1,23 @@ +# +# Copyright © 2025 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +[containers] +default_sysctls = [ + "net.ipv4.ping_group_range=0 0", +] + +[engine] +cgroup_manager = "cgroupfs" diff --git a/test/system/config/dbus-session.conf b/test/system/config/dbus-session.conf new file mode 100644 index 000000000..7fd165bb1 --- /dev/null +++ b/test/system/config/dbus-session.conf @@ -0,0 +1,29 @@ + + + + + + unix:runtime=yes + + + + + + + session + diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash index 33b42eaf6..3820f045c 100644 --- a/test/system/libs/helpers.bash +++ b/test/system/libs/helpers.bash @@ -15,15 +15,21 @@ export XDG_CONFIG_HOME readonly XDG_DATA_HOME="$HOME/.local/share" export XDG_DATA_HOME -readonly XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$UID}" +readonly XDG_RUNTIME_DIR="$BATS_SUITE_TMPDIR/xdg-runtime-dir" export XDG_RUNTIME_DIR readonly XDG_STATE_HOME="$HOME/.local/state" export XDG_STATE_HOME +readonly CONTAINERS_CONF="$BATS_TEST_DIRNAME/config/containers.conf" +export CONTAINERS_CONF + readonly CONTAINERS_STORAGE_CONF="$XDG_CONFIG_HOME/containers/storage.conf" export CONTAINERS_STORAGE_CONF +readonly DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus" +export DBUS_SESSION_BUS_ADDRESS + # Helpful globals readonly IMAGE_CACHE_DIR="$BATS_SUITE_TMPDIR/image-cache" readonly TOOLBX_ROOTLESS_STORAGE_PATH="$XDG_DATA_HOME/containers/storage" @@ -49,14 +55,39 @@ declare -Ag IMAGES=([arch]="quay.io/toolbx/arch-toolbox" \ function cleanup_all() { - podman rm --all --force >/dev/null - podman rmi --all --force >/dev/null + ctr_id="$(podman ps --all --format "{{ .ID }}" --no-trunc | head --lines 1)" + cat "$XDG_RUNTIME_DIR/crun/$ctr_id/status" + echo "Container to kill: $ctr_id" + if [ "$ctr_id" != "" ]; then + crun --debug --log-level=debug kill --all "$ctr_id" 15 + echo "Container to kill: crun: $?" + fi + + ctr_id="$(podman ps --all --format "{{ .ID }}" --no-trunc | head --lines 2 | tail --lines 1)" + echo "Container to kill: $ctr_id" + if [ "$ctr_id" != "" ]; then + crun --debug --log-level=debug kill --all "$ctr_id" 15 + echo "Container to kill: crun: $?" + fi + + ctr_id="$(podman ps --all --format "{{ .ID }}" --no-trunc | head --lines 3 | tail --lines 1)" + echo "Container to kill: $ctr_id" + if [ "$ctr_id" != "" ]; then + crun --debug --log-level=debug kill --all "$ctr_id" 15 + echo "Container to kill: crun: $?" + fi + + podman --log-level debug stop --all + podman rm --all + podman rmi --all } function _setup_environment() { # shellcheck disable=SC2174 mkdir --mode 700 --parents "$HOME" + mkdir --mode 0700 --parents "$XDG_RUNTIME_DIR" + _setup_containers_storage } diff --git a/test/system/setup_suite.bash b/test/system/setup_suite.bash index f564f7ecb..423d4dc76 100644 --- a/test/system/setup_suite.bash +++ b/test/system/setup_suite.bash @@ -15,6 +15,7 @@ # limitations under the License. # +dbus_daemon_pid=0 missing_dependencies=false if [ -f "$BATS_TEST_DIRNAME/libs/bats-assert/load.bash" ] && [ -f "$BATS_TEST_DIRNAME/libs/bats-support/load.bash" ]; then @@ -40,6 +41,7 @@ setup_suite() { system_version="$(get_system_version)" _setup_environment + dbus_daemon_pid="$(dbus-daemon --config-file "$BATS_TEST_DIRNAME/config/dbus-session.conf" --print-pid)" if echo "$TOOLBX_TEST_SYSTEM_TAGS" | grep "arch" >/dev/null 2>/dev/null; then _pull_and_cache_distro_image arch latest || false @@ -67,7 +69,7 @@ setup_suite() { _pull_and_cache_distro_image fedora "$((system_version-2))" || false fi - _setup_docker_registry + # _setup_docker_registry fi } @@ -79,9 +81,14 @@ teardown_suite() { return 0 fi - if echo "$TOOLBX_TEST_SYSTEM_TAGS" | grep "commands-options" >/dev/null 2>/dev/null; then - _clean_docker_registry + if [ "$dbus_daemon_pid" != 0 ]; then + kill -s SIGTERM "$dbus_daemon_pid" + dbus_daemon_pid=0 fi + # if echo "$TOOLBX_TEST_SYSTEM_TAGS" | grep "commands-options" >/dev/null 2>/dev/null; then + # _clean_docker_registry + # fi + podman system reset --force >/dev/null }