diff --git a/tests/integration/mounts.bats b/tests/integration/mounts.bats index 1e72c5b14..9ecf87ccf 100644 --- a/tests/integration/mounts.bats +++ b/tests/integration/mounts.bats @@ -64,19 +64,28 @@ function teardown() { [ "$status" -eq 0 ] } +@test "runc run [ro /sys/fs/cgroup mounts]" { + # Without cgroup namespace. + update_config '.linux.namespaces -= [{"type": "cgroup"}]' + test_ro_cgroup_mount +} + +# shellcheck disable=SC2030 +@test "runc run [ro /sys/fs/cgroup mounts + cgroupns]" { + requires cgroupns + # With cgroup namespace. + update_config '.linux.namespaces |= if index({"type": "cgroup"}) then . else . + [{"type": "cgroup"}] end' + test_ro_cgroup_mount +} + # https://github.com/opencontainers/runc/security/advisories/GHSA-m8cg-xc2p-r3fc -@test "runc run [ro /sys/fs/cgroup mount]" { - # With cgroup namespace +# shellcheck disable=SC2031 +function test_ro_cgroup_mount() { + local lines status + # shellcheck disable=SC2016 update_config '.process.args |= ["sh", "-euc", "for f in `grep /sys/fs/cgroup /proc/mounts | awk \"{print \\\\$2}\"| uniq`; do grep -w $f /proc/mounts | tail -n1; done"]' runc run test_busybox [ "$status" -eq 0 ] [ "${#lines[@]}" -ne 0 ] for line in "${lines[@]}"; do [[ "${line}" == *'ro,'* ]]; done - - # Without cgroup namespace - update_config '.linux.namespaces -= [{"type": "cgroup"}]' - runc run test_busybox - [ "$status" -eq 0 ] - [ "${#lines[@]}" -ne 0 ] - for line in "${lines[@]}"; do [[ "${line}" == *'ro,'* ]]; done }