mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
integration: reuse tmpfs for directory masks
Co-authored-by: Davanum Srinivas <davanum@gmail.com>
Signed-off-by: lifubang <lifubang@acmcoder.com>
(cherry picked from commit 124772f354)
Signed-off-by: lifubang <lifubang@acmcoder.com>
This commit is contained in:
@@ -6,7 +6,7 @@ function setup() {
|
||||
setup_busybox
|
||||
|
||||
# Create fake rootfs.
|
||||
mkdir rootfs/testdir
|
||||
mkdir rootfs/testdir rootfs/testdir2 rootfs/testdir3
|
||||
echo "Forbidden information!" >rootfs/testfile
|
||||
|
||||
# add extra masked paths
|
||||
@@ -87,3 +87,33 @@ function teardown() {
|
||||
# so we merely check that it fails, and do not check the exact error
|
||||
# message like for /proc above.
|
||||
}
|
||||
|
||||
@test "mask paths [directories share tmpfs]" {
|
||||
update_config '(.. | select(.maskedPaths? != null)) .maskedPaths += ["/testdir2", "/testdir3"]'
|
||||
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
runc exec test_busybox sh -euc '
|
||||
set -- $(stat -c %d /testdir /testdir2 /testdir3)
|
||||
[ "$1" = "$2" ]
|
||||
[ "$2" = "$3" ]
|
||||
'
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
runc exec test_busybox touch /testdir2/foo
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "${output}" == *"Read-only file system"* ]]
|
||||
}
|
||||
|
||||
@test "mask paths [directory with read-only rootfs]" {
|
||||
update_config '(.. | select(.maskedPaths? != null)) .maskedPaths += ["/testdir2", "/testdir3"]'
|
||||
update_config '.root.readonly = true'
|
||||
|
||||
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
runc exec test_busybox ls /testdir
|
||||
[ "$status" -eq 0 ]
|
||||
[ -z "$output" ]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user