Commit 3a66660e authored by Pavel Tikhomirov's avatar Pavel Tikhomirov Committed by Andrei Vagin

zdtm: shared options should not be lost for bind mounts

1150 1371 0:169 / /zdtm/static/private_bind_propagation.test rw,relatime shared:920 - tmpfs zdtm_fs rw
1151 1150 0:170 / /zdtm/static/private_bind_propagation.test/share1 rw,relatime shared:921 - tmpfs share rw
1152 1150 0:170 / /zdtm/static/private_bind_propagation.test/share2 rw,relatime shared:921 - tmpfs share rw
1153 1151 0:169 /source /zdtm/static/private_bind_propagation.test/share1/child rw,relatime - tmpfs zdtm_fs rw
1154 1152 0:169 /source /zdtm/static/private_bind_propagation.test/share2/child rw,relatime - tmpfs zdtm_fs rw
Signed-off-by: 's avatarPavel Tikhomirov <ptikhomirov@virtuozzo.com>
parent 6c81e877
......@@ -339,6 +339,7 @@ TST_DIR = \
unsupported_children_collision \
shared_slave_mount_children \
non_uniform_share_propagation \
private_bind_propagation \
TST_DIR_FILE = \
chroot \
......
#include <sys/mount.h>
#include <sys/stat.h>
#include <limits.h>
#include "zdtmtst.h"
const char *test_doc = "Check sharing options are restored for bindmounted shared group children";
const char *test_author = "Pavel Tikhomirov <ptikhomirov@virtuozzo.com>";
char *dirname;
TEST_OPTION(dirname, string, "directory name", 1);
int main(int argc, char **argv)
{
char share1[PATH_MAX], share2[PATH_MAX], source[PATH_MAX];
char child1[PATH_MAX], child2[PATH_MAX];
test_init(argc, argv);
if (mkdir(dirname, 0700)) {
pr_perror("mkdir");
return 1;
}
if (mount("zdtm_fs", dirname, "tmpfs", 0, NULL)) {
pr_perror("mount");
return 1;
}
if (mount(NULL, dirname, NULL, MS_SHARED, NULL)) {
pr_perror("mount");
return 1;
}
snprintf(share1, sizeof(share1), "%s/share1", dirname);
if (mkdir(share1, 0700)) {
pr_perror("mkdir");
return 1;
}
if (mount("share", share1, "tmpfs", 0, NULL)) {
pr_perror("mount");
return 1;
}
if (mount(NULL, share1, NULL, MS_SHARED, NULL)) {
pr_perror("mount");
return 1;
}
snprintf(share2, sizeof(share2), "%s/share2", dirname);
if (mkdir(share2, 0700)) {
pr_perror("mkdir");
return 1;
}
if (mount(share1, share2, NULL, MS_BIND, NULL)) {
pr_perror("mount");
return 1;
}
snprintf(source, sizeof(source), "%s/source", dirname);
if (mkdir(source, 0700)) {
pr_perror("mkdir");
return 1;
}
snprintf(child1, sizeof(child1), "%s/share1/child", dirname);
snprintf(child2, sizeof(child2), "%s/share1/child", dirname);
if (mkdir(child1, 0700)) {
pr_perror("mkdir");
return 1;
}
if (mount(source, child1, NULL, MS_BIND, NULL)) {
pr_perror("mount");
return 1;
}
if (mount(NULL, child1, NULL, MS_PRIVATE, NULL)) {
pr_perror("mount");
return 1;
}
if (mount(NULL, child2, NULL, MS_PRIVATE, NULL)) {
pr_perror("mount");
return 1;
}
test_daemon();
test_waitsig();
if (umount(child1)) {
pr_perror("Unable to umount %s", child1);
return 1;
}
if (umount(share1)) {
pr_perror("Unable to umount %s", share1);
return 1;
}
if (umount(share2)) {
pr_perror("Unable to umount %s", share2);
return 1;
}
if (umount(dirname)) {
pr_perror("Unable to umount %s", dirname);
return 1;
}
pass();
return 0;
}
{'flavor': 'ns uns', 'flags': 'suid'}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment