]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
tests/lxc-test-rootfs: add idmapped rootfs testcase
authorAlexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Tue, 29 Jul 2025 09:32:13 +0000 (11:32 +0200)
committerAlexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Tue, 29 Jul 2025 09:32:13 +0000 (11:32 +0200)
I've discovered that we have no test coverage for rootfs
"lxc.rootfs.options = idmap=container" at all.

Let's add this basic test at least.

Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
src/tests/lxc-test-rootfs

index 9deaf18a4812caaa8ae30fa4904368894ac3341a..bd9bb069ee9bcfda617ad67e73b35f38e72c50a6 100755 (executable)
@@ -9,6 +9,7 @@ set -ex
 cleanup() {
        set +e
        lxc-destroy -n lxc-test-rootfs -f
+       sed -i '/^root:910000:10000/d' /etc/subuid /etc/subgid
        if [ $PHASE != "done" ]; then
                echo "rootfs test failed at $PHASE"
                exit 1
@@ -48,4 +49,20 @@ mkdir /proc/$pid/root/rwtest || ro=1
 rmdir /proc/$pid/root/rwtest
 ro=0
 
+lxc-stop -n lxc-test-rootfs -k
+PHASE=idmapped_rootfs
+echo "Starting phase $PHASE"
+usermod -v 910000-919999 -w 910000-919999 root
+sed -i '/lxc.rootfs.options/d' $config
+echo "lxc.idmap = u 0 910000 9999" >> $config
+echo "lxc.idmap = g 0 910000 9999" >> $config
+echo "lxc.rootfs.options = idmap=container" >> $config
+lxc-start -n lxc-test-rootfs
+pid=$(lxc-info -n lxc-test-rootfs -p -H)
+ro=0
+lxc-attach -n lxc-test-rootfs -- mkdir /rwtest || ro=1
+[ $ro -ne 1 ]
+rmdir /proc/$pid/root/rwtest
+ro=0
+
 PHASE=done