if (ret < 0)
return log_error_errno(-1, errno, "Failed to unshare mount namespace");
- if (detect_shared_rootfs()) {
- if (mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL)) {
- SYSERROR("Failed to make / rslave");
- ERROR("Continuing...");
- }
- }
+ if (detect_shared_rootfs() && mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL))
+ SYSERROR("Failed to recursively turn root mount tree into dependent mount. Continuing...");
/* Assume /proc is always mounted, so remount it. */
ret = umount2("/proc", MNT_DETACH);
if (detect_shared_rootfs()) {
ret = mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL);
if (ret < 0) {
- CMD_SYSINFO("Failed to make \"/\" rslave");
+ CMD_SYSINFO("Failed to recursively turn root mount tree into dependent mount");
return -1;
}
}
if (!rootfs->path) {
ret = mount("", "/", NULL, MS_SLAVE | MS_REC, 0);
if (ret < 0)
- return log_error_errno(-1, errno, "Failed to remount \"/\" MS_REC | MS_SLAVE");
+ return log_error_errno(-1, errno, "Failed to recursively turn root mount tree into dependent mount");
return 0;
}
if (ret < 0)
return log_error_errno(-1, errno, "Failed to enter old root directory");
- /* Make oldroot rslave to make sure our umounts don't propagate to the
+ /* Make oldroot a depedent mount to make sure our umounts don't propagate to the
* host.
*/
ret = mount("", ".", "", MS_SLAVE | MS_REC, NULL);
if (ret < 0)
- return log_error_errno(-1, errno, "Failed to make oldroot rslave");
+ return log_error_errno(-1, errno, "Failed to recursively turn old root mount tree into dependent mount");
ret = umount2(".", MNT_DETACH);
if (ret < 0)
lxc_conf->tmp_umount_proc = false;
}
-/* Walk /proc/mounts and change any shared entries to slave. */
-void remount_all_slave(void)
+/* Walk /proc/mounts and change any shared entries to dependent mounts. */
+void turn_into_dependent_mounts(void)
{
__do_free char *line = NULL;
__do_fclose FILE *f = NULL;
null_endofword(target);
ret = mount(NULL, target, NULL, MS_SLAVE, NULL);
if (ret < 0) {
- SYSERROR("Failed to make \"%s\" MS_SLAVE", target);
- ERROR("Continuing...");
+ SYSERROR("Failed to recursively turn old root mount tree into dependent mount. Continuing...");
continue;
}
- TRACE("Remounted \"%s\" as MS_SLAVE", target);
+ TRACE("Recursively turned old root mount tree into dependent mount");
}
- TRACE("Remounted all mount table entries as MS_SLAVE");
+ TRACE("Turned all mount table entries into dependent mount");
}
static int lxc_execute_bind_init(struct lxc_handler *handler)
return log_trace(0, "Bind mounted container / onto itself");
}
- remount_all_slave();
+ turn_into_dependent_mounts();
ret = run_lxc_hooks(name, "pre-mount", conf, NULL);
if (ret < 0)
char **mntdata);
extern int parse_propagationopts(const char *mntopts, unsigned long *pflags);
extern void tmp_proc_unmount(struct lxc_conf *lxc_conf);
-extern void remount_all_slave(void);
+extern void turn_into_dependent_mounts(void);
extern void suggest_default_idmap(void);
extern FILE *make_anonymous_mount_file(struct lxc_list *mount,
bool include_nesting_helpers);
" # deny reads from debugfs\n"
" deny /sys/kernel/debug/{,**} rwklx,\n"
"\n"
-" # allow paths to be made slave, shared, private or unbindable\n"
+" # allow paths to be made dependent, shared, private or unbindable\n"
" # TODO: This currently doesn't work due to the apparmor parser treating those as allowing all mounts.\n"
"# mount options=(rw,make-slave) -> **,\n"
"# mount options=(rw,make-rslave) -> **,\n"
ret = mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL);
if (ret < 0) {
- SYSERROR("Failed to make / rslave at startup");
+ SYSERROR("Failed to recursively turn root mount tree into dependent mount. Continuing...");
lxc_put_handler(handler);
ret = 1;
goto on_error;
_exit(EXIT_FAILURE);
}
- ret = detect_shared_rootfs();
- if (ret == 1) {
- ret = mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL);
- if (ret < 0) {
- SYSERROR("Failed to make \"/\" rslave");
- ERROR("Continuing...");
- }
- }
+ if (detect_shared_rootfs() && mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL))
+ SYSERROR("Failed to recursively turn root mount tree into dependent mount. Continuing...");
}
if (strcmp(bdev->type, "dir") != 0 && strcmp(bdev->type, "btrfs") != 0) {
return -1;
}
- if (detect_shared_rootfs()) {
- if (mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL)) {
- SYSERROR("Failed to make / rslave");
- ERROR("Continuing...");
- }
- }
+ if (detect_shared_rootfs() && mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL))
+ SYSERROR("Failed to recursively turn root mount tree into dependent mount. Continuing...");
if (bdev->ops->mount(bdev) < 0) {
storage_put(bdev);
}
INFO("Unshared CLONE_NEWNS");
- remount_all_slave();
+ turn_into_dependent_mounts();
ret = lxc_setup_rootfs_prepare_root(conf, name, lxcpath);
if (ret < 0) {
ERROR("Error setting up rootfs mount as root before spawn");
return -1;
}
- ret = detect_shared_rootfs();
- if (ret) {
- ret = mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL);
- if (ret < 0)
- SYSERROR("Failed to make \"/\" a slave mount");
- }
+ if (detect_shared_rootfs() && mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL))
+ SYSERROR("Failed to recursively turn root mount tree into dependent mount");
ret = orig->ops->mount(orig);
if (ret < 0) {
if (unshare(CLONE_NEWNS) < 0)
_exit(EXIT_FAILURE);
- if (detect_shared_rootfs())
- if (mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL)) {
- SYSERROR("Failed to make / rslave");
- ERROR("Continuing...");
- }
+ if (detect_shared_rootfs() && mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL))
+ SYSERROR("Failed to recursively turn root mount tree into dependent mount. Continuing...");
ret = mount_unknown_fs(srcdev, bdev->dest, bdev->mntopts);
if (ret < 0) {