]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
tests: skip unpriv tests on broken overlay module
authorChristian Brauner <christian.brauner@ubuntu.com>
Sun, 25 Dec 2016 11:26:17 +0000 (12:26 +0100)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 3 Jan 2017 15:52:02 +0000 (10:52 -0500)
This mainly affects Trusty. The 3.13 kernel has a broken overlay module which
does not handle symlinks correctly. This is a problem for containers that use
an overlay based rootfs since safe_mount() uses /proc/<pid>/fd/<fd-number> in
its calls to mount().

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/tests/lxc-test-unpriv

index 93c91a9f4ee9b7ca2b9f4b11f538947a01391513..54ddc6637df90909d7f4d9984405da65cb9a2b29 100755 (executable)
@@ -27,6 +27,41 @@ if [ $(id -u) -ne 0 ]; then
        echo "ERROR: Must run as root."
        exit 1
 fi
+
+# Test if we're using an overlayfs module that handles symlinks correctly. If
+# not, we skip these tests since overlay clones will not work correctly.
+if modprobe -q overlayfs; then
+        TMPDIR=$(mktemp -d)
+
+        MOUNTDIR="${TMPDIR}/ovl_symlink_test"
+
+        mkdir ${MOUNTDIR}
+
+        mount -t tmpfs none ${MOUNTDIR}
+
+        mkdir "${MOUNTDIR}/lowerdir" "${MOUNTDIR}/upperdir" "${MOUNTDIR}/overlayfs"
+        mount -t overlayfs -o lowerdir="${MOUNTDIR}/lowerdir",upperdir="${MOUNTDIR}/upperdir" none "${MOUNTDIR}/overlayfs"
+
+        CORRECT_LINK_TARGET="${MOUNTDIR}/overlayfs/dummy_file"
+        exec 9> "${CORRECT_LINK_TARGET}"
+
+        DETECTED_LINK_TARGET=$(readlink -q /proc/$$/fd/9)
+
+        # cleanup
+        exec 9>&-
+
+        umount "${MOUNTDIR}/overlayfs"
+        umount ${MOUNTDIR}
+
+        rmdir ${MOUNTDIR}
+
+        # This overlay module does not correctly handle symlinks, so skip the
+        # tests.
+        if [ "${DETECTED_LINK_TARGET}" != "${CORRECT_LINK_TARGET}" ]; then
+                exit 0
+        fi
+fi
+
 which newuidmap >/dev/null 2>&1 || { echo "'newuidmap' command is missing" >&2; exit 1; }
 
 DONE=0