Skip to content

Commit

Permalink
Merge pull request #1547 from brauner/2017-05-10/prevent_umount_propa…
Browse files Browse the repository at this point in the history
…gation

start: remove umount2()
  • Loading branch information
hallyn committed May 10, 2017
2 parents eb09dc4 + 39c7b79 commit 60883ba
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
31 changes: 21 additions & 10 deletions src/lxc/conf.c
Expand Up @@ -1287,23 +1287,23 @@ int prepare_ramfs_root(char *root)
char *p2;

if (realpath(root, nroot) == NULL)
return -1;
return -errno;

if (chdir("/") == -1)
return -1;
return -errno;

/*
* We could use here MS_MOVE, but in userns this mount is
* locked and can't be moved.
*/
if (mount(root, "/", NULL, MS_REC | MS_BIND, NULL)) {
if (mount(root, "/", NULL, MS_REC | MS_BIND, NULL) < 0) {
SYSERROR("Failed to move %s into /", root);
return -1;
return -errno;
}

if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL)) {
if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL) < 0) {
SYSERROR("Failed to make . rprivate");
return -1;
return -errno;
}

/*
Expand Down Expand Up @@ -1369,17 +1369,28 @@ int prepare_ramfs_root(char *root)

static int setup_pivot_root(const struct lxc_rootfs *rootfs)
{
if (!rootfs->path)
if (!rootfs->path) {
DEBUG("container does not have a rootfs, so not doing pivot root");
return 0;
}

if (detect_ramfs_rootfs()) {
if (prepare_ramfs_root(rootfs->mount))
DEBUG("detected that container is on ramfs");
if (prepare_ramfs_root(rootfs->mount)) {
ERROR("failed to prepare minimal ramfs root");
return -1;
} else if (setup_rootfs_pivot_root(rootfs->mount)) {
ERROR("failed to setup pivot root");
}

DEBUG("prepared ramfs root for container");
return 0;
}

if (setup_rootfs_pivot_root(rootfs->mount) < 0) {
ERROR("failed to pivot root");
return -1;
}

DEBUG("finished pivot root");
return 0;
}

Expand Down
3 changes: 0 additions & 3 deletions src/lxc/start.c
Expand Up @@ -1289,9 +1289,6 @@ static int lxc_spawn(struct lxc_handler *handler)
if (lxc_sync_barrier_child(handler, LXC_SYNC_POST_CGROUP))
return -1;

if (detect_shared_rootfs())
umount2(handler->conf->rootfs.mount, MNT_DETACH);

if (handler->ops->post_start(handler, handler->data))
goto out_abort;

Expand Down

0 comments on commit 60883ba

Please sign in to comment.