Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit bf61d63

Browse files
committed
enter the sandbox when hyper_setup_container_rootfs()
Signed-off-by: Lai Jiangshan <[email protected]>
1 parent 74f6930 commit bf61d63

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/container.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ static int container_setup_mount(struct hyper_container *container)
269269
hyper_mkdir("./dev", 0755);
270270
hyper_mkdir("./lib/modules", 0755);
271271

272-
// mount proc filesystem when the container init process running in the pidns of podinit
273-
if (mount("sysfs", "./sys", "sysfs", MS_NOSUID| MS_NODEV| MS_NOEXEC, NULL) < 0 ||
272+
if (mount("proc", "./proc", "proc", MS_NOSUID| MS_NODEV| MS_NOEXEC, NULL) < 0 ||
273+
mount("sysfs", "./sys", "sysfs", MS_NOSUID| MS_NODEV| MS_NOEXEC, NULL) < 0 ||
274274
mount("devtmpfs", "./dev", "devtmpfs", MS_NOSUID, NULL) < 0) {
275275
perror("mount basic filesystem for container failed");
276276
return -1;
@@ -512,6 +512,11 @@ static int hyper_setup_container_rootfs(void *data)
512512
int setup_dns;
513513
uint32_t type;
514514

515+
if (hyper_enter_sandbox(arg->pod, -1) < 0) {
516+
perror("enter sandbox failed");
517+
goto fail;
518+
}
519+
515520
if (hyper_rescan_scsi() < 0) {
516521
fprintf(stdout, "rescan scsi failed\n");
517522
goto fail;

src/exec.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <sys/ioctl.h>
99
#include <sys/wait.h>
1010
#include <sys/socket.h>
11-
#include <sys/mount.h>
1211
#include <dirent.h>
1312
#include <sched.h>
1413
#include <errno.h>
@@ -519,12 +518,6 @@ static int hyper_do_exec_cmd(struct hyper_exec *exec, struct hyper_pod *pod, int
519518
goto out;
520519
}
521520

522-
/* already in pidns & mntns of container, mount proc filesystem */
523-
if (exec->init && mount("proc", "/proc", "proc", MS_NOSUID| MS_NODEV| MS_NOEXEC, NULL) < 0) {
524-
perror("fail to mount proc filesystem for container");
525-
goto out;
526-
}
527-
528521
// set early env. the container env config can overwrite it
529522
setenv("HOME", "/root", 1);
530523
setenv("HOSTNAME", pod->hostname, 1);

0 commit comments

Comments
 (0)