another test for linux namespace. They works perfectly

This commit is contained in:
roberto@fedora64
2011-01-02 17:51:50 +00:00
parent 924074175e
commit d586fe2fb3
2 changed files with 7 additions and 2 deletions
+6 -2
View File
@@ -663,7 +663,6 @@ options_parsed:
#ifndef CLONE_NEWIPC
#define CLONE_NEWIPC 0x08000000
#endif
uwsgi.ns = "/ns/001";
if (uwsgi.ns) {
void *linux_clone_stack = alloca(uwsgi.page_size);
pid_t pid = clone(uwsgi_start, linux_clone_stack+uwsgi.page_size, SIGCHLD|CLONE_NEWUTS|CLONE_NEWPID|CLONE_NEWIPC|CLONE_NEWNS, (void *)argv);
@@ -710,6 +709,9 @@ int uwsgi_start(void *v_argv) {
uwsgi_log("my PID is %d\n", (int) getpid());
if (getpid() == 1) {
if (sethostname("uwsgifakehost", strlen("uwsgifakehost"))) {
uwsgi_error("sethostname()");
}
uwsgi_log("unmounting /proc\n");
if (umount("/proc/bus/usb")) {
uwsgi_error("umount()");
@@ -731,7 +733,7 @@ int uwsgi_start(void *v_argv) {
umount("/home/roberto/.gvfs");
umount("/sys");
umount("/");
if (mount("/ns/001", "/ns/001_", "none", MS_BIND| MS_REC, NULL)) {
if (mount(uwsgi.ns, "/ns/001_", "none", MS_BIND, NULL)) {
uwsgi_error("mount()");
}
if (chdir("/ns/001_")) {
@@ -740,6 +742,8 @@ int uwsgi_start(void *v_argv) {
if (pivot_root(".", "/ns/001_/mnt2")) {
uwsgi_error("pivot_root()");
}
umount("/ns/001_/mnt2");
if (mount("proc","/proc", "proc", 0, NULL)) {
uwsgi_error("mount()");
+1
View File
@@ -272,6 +272,7 @@ struct uwsgi_opt {
#define LONG_ARGS_CLUSTER_RELOAD 17063
#define LONG_ARGS_CLUSTER_LOG 17064
#define LONG_ARGS_CACHE 17065
#define LONG_ARGS_NS 17066