From aa9a5fbb99a3149ecd07769727e36ec93df01718 Mon Sep 17 00:00:00 2001 From: Jacques de Laval Date: Wed, 17 Feb 2021 16:20:17 +0100 Subject: [PATCH] WIP: Unshare/Chroot test wrapper script --- test/run.sh | 15 +++++++++++++++ test/testwrapper.sh | 9 +++++++++ 2 files changed, 24 insertions(+) create mode 100755 test/run.sh create mode 100755 test/testwrapper.sh diff --git a/test/run.sh b/test/run.sh new file mode 100755 index 00000000..399bdb8b --- /dev/null +++ b/test/run.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +set -eux + +TEST_DIR=$(dirname "$0") +TESTS_ROOT="${TEST_DIR}/test_root" + +cp "${TEST_DIR}/testwrapper.sh" "${TESTS_ROOT}/usr/local/bin/" + +unshare \ + --user --map-root-user \ + --fork --pid --mount-proc \ + --mount \ + --mount-proc \ + chroot "$TESTS_ROOT" /usr/local/bin/testwrapper.sh "$@" diff --git a/test/testwrapper.sh b/test/testwrapper.sh new file mode 100755 index 00000000..ec4be152 --- /dev/null +++ b/test/testwrapper.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +set -eux + +export PATH=/sbin:/bin + +mount -t proc none /proc + +exec "$@"