using fedora14 as base for linux namespace support

This commit is contained in:
roberto@fedora64
2011-01-02 18:20:20 +01:00
parent a64cbea6e8
commit 924074175e
3 changed files with 45 additions and 2 deletions
+38 -1
View File
@@ -666,7 +666,7 @@ options_parsed:
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, (void *)argv);
pid_t pid = clone(uwsgi_start, linux_clone_stack+uwsgi.page_size, SIGCHLD|CLONE_NEWUTS|CLONE_NEWPID|CLONE_NEWIPC|CLONE_NEWNS, (void *)argv);
if (pid == -1) {
uwsgi_error("clone()");
exit(1);
@@ -709,6 +709,43 @@ int uwsgi_start(void *v_argv) {
uwsgi_log("my PID is %d\n", (int) getpid());
if (getpid() == 1) {
uwsgi_log("unmounting /proc\n");
if (umount("/proc/bus/usb")) {
uwsgi_error("umount()");
}
if (umount("/proc/sys/fs/binfmt_misc")) {
uwsgi_error("umount()");
}
if (umount("/proc")) {
uwsgi_error("umount()");
}
umount("/dev/pts");
umount("/dev/shm");
umount("/dev");
umount("/dev");
umount("/sys/fs/fuse/connections");
umount("/sys");
umount("/boot");
umount("/selinux");
umount("/home/roberto/.gvfs");
umount("/sys");
umount("/");
if (mount("/ns/001", "/ns/001_", "none", MS_BIND| MS_REC, NULL)) {
uwsgi_error("mount()");
}
if (chdir("/ns/001_")) {
uwsgi_error("chdir()");
}
if (pivot_root(".", "/ns/001_/mnt2")) {
uwsgi_error("pivot_root()");
}
if (mount("proc","/proc", "proc", 0, NULL)) {
uwsgi_error("mount()");
}
}
uwsgi_as_root();
if (!uwsgi.no_initial_output) {
+2
View File
@@ -84,6 +84,8 @@
#ifdef __linux
#include <sys/prctl.h>
#include <linux/limits.h>
#include <sys/mount.h>
extern int pivot_root(const char * new_root, const char * put_old);
#else
#include <limits.h>
#endif
+5 -1
View File
@@ -141,7 +141,11 @@ class uConf(object):
self.config.read(filename)
self.gcc_list = ['utils', 'protocol', 'socket', 'logging', 'master', 'plugins', 'lock', 'cache', 'event', 'signal', 'loop', 'uwsgi']
self.cflags = ['-O2', '-Wall', '-Werror', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64'] + os.environ.get("CFLAGS", "").split()
gcc_version = str(spcall2("%s -v" % GCC)).split('\n')[-1].split()[2]
try:
gcc_version = str(spcall2("%s -v" % GCC)).split('\n')[-1].split()[2]
except:
print("*** you need a c compiler to build uWSGI ***")
sys.exit(1)
gcc_major = int(gcc_version.split('.')[0])
gcc_minor = int(gcc_version.split('.')[1])
if (sys.version_info[0] == 2) or (gcc_major < 4) or (gcc_major == 4 and gcc_minor < 3):