Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/checkpoint-restore/criu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Tikhomirov <ptikhomirov@virtuozzo.com>2022-06-20 12:54:29 +0300
committerAndrei Vagin <avagin@gmail.com>2022-06-22 20:20:33 +0300
commitf29d51560ee5ac3fb11ab8e4034938ff21242f17 (patch)
tree2aeae6581b6c8fc12510cdbb83ac52472d7b5134
parent8a18faea09c9d7062baac83e00000ae8ad542ee3 (diff)
zdtm: add mnt_root_ext test
This test has one external mount [criumntns] /zdtm_root_ext.tmp -> [testmntns] /mnt_root_ext.test, and it specifically gives '--external mnt[MNT]:.zdtm_root_ext.tmp' option on restore without '/' to make dirname on it return static '.' path (see glibc dirname() code) and reproduce a segfault in resolve_mountpoint(). Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
-rw-r--r--test/zdtm/static/Makefile1
-rw-r--r--test/zdtm/static/mnt_root_ext.c79
-rw-r--r--test/zdtm/static/mnt_root_ext.desc5
-rwxr-xr-xtest/zdtm/static/mnt_root_ext.hook5
4 files changed, 90 insertions, 0 deletions
diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index 761bf0f6c..4a93659d4 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -402,6 +402,7 @@ TST_DIR = \
mnt_ext_master \
mnt_ext_dev \
mnt_ext_root \
+ mnt_root_ext \
mnt_ext_collision \
mntns_pivot_root \
mntns_pivot_root_ro \
diff --git a/test/zdtm/static/mnt_root_ext.c b/test/zdtm/static/mnt_root_ext.c
new file mode 100644
index 000000000..6a2eb068c
--- /dev/null
+++ b/test/zdtm/static/mnt_root_ext.c
@@ -0,0 +1,79 @@
+#include <sched.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <linux/limits.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc = "Check external mount from host's rootfs";
+const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>";
+
+char *dirname = "mnt_root_ext.test";
+TEST_OPTION(dirname, string, "directory name", 1);
+
+int main(int argc, char **argv)
+{
+ char *root, testdir[PATH_MAX], nstestdir[PATH_MAX];
+ char *zdtm_newns = getenv("ZDTM_NEWNS");
+ char tmp[] = "/.zdtm_root_ext.tmp";
+
+ root = getenv("ZDTM_ROOT");
+ if (root == NULL) {
+ pr_perror("root");
+ return 1;
+ }
+
+ if (!zdtm_newns) {
+ pr_perror("ZDTM_NEWNS is not set");
+ return 1;
+ } else if (strcmp(zdtm_newns, "1")) {
+ goto test;
+ }
+
+ /* Prepare directories in test root */
+ sprintf(testdir, "%s/%s", root, dirname);
+ mkdir(testdir, 0755);
+
+ /* Prepare directories in criu root */
+ mkdir(tmp, 0755);
+
+ /* Make criu's mntns root mount shared */
+ if (mount(NULL, "/", NULL, MS_SHARED, NULL)) {
+ pr_perror("make shared");
+ return 1;
+ }
+
+ /*
+ * Create temporary mntns, next mounts will not show up in criu mntns
+ */
+ if (unshare(CLONE_NEWNS)) {
+ pr_perror("unshare");
+ return 1;
+ }
+
+ /*
+ * Populate to the tests root host's rootfs subdir
+ */
+ if (mount(tmp, testdir, NULL, MS_BIND, NULL)) {
+ pr_perror("bind");
+ return 1;
+ }
+test:
+ test_init(argc, argv);
+
+ /*
+ * Make "external" mount to be slave
+ */
+ sprintf(nstestdir, "/%s", dirname);
+ if (mount(NULL, nstestdir, NULL, MS_SLAVE, NULL)) {
+ pr_perror("make slave");
+ return 1;
+ }
+
+ test_daemon();
+ test_waitsig();
+
+ pass();
+
+ return 0;
+}
diff --git a/test/zdtm/static/mnt_root_ext.desc b/test/zdtm/static/mnt_root_ext.desc
new file mode 100644
index 000000000..fee7efbae
--- /dev/null
+++ b/test/zdtm/static/mnt_root_ext.desc
@@ -0,0 +1,5 @@
+{ 'dopts': '--external mnt[/mnt_root_ext.test]:MNT',
+ 'feature': 'mnt_id move_mount_set_group',
+ 'flavor': 'ns uns',
+ 'flags': 'suid',
+ 'ropts': '--external mnt[MNT]:.zdtm_root_ext.tmp --no-mntns-compat-mode'}
diff --git a/test/zdtm/static/mnt_root_ext.hook b/test/zdtm/static/mnt_root_ext.hook
new file mode 100755
index 000000000..a5286f208
--- /dev/null
+++ b/test/zdtm/static/mnt_root_ext.hook
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+[ "$1" == "--clean" ] || exit 0
+
+rmdir /.zdtm_root_ext.tmp