From e7fb216a8dff658f4cdccdeb8dcad7dd4c35ccc8 Mon Sep 17 00:00:00 2001 From: Damjan Georgievski Date: Fri, 6 Sep 2013 08:41:00 +0200 Subject: [PATCH] remount to private subtree after unshare systemd will makes the VFS tree 'shared' on boot, so mount operations would propagate between the namespace and the parent system. make sure the whole VFS tree is private to the namespace. --- lib/linux_ns.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/linux_ns.c b/lib/linux_ns.c index 3814d56c..7cdf7fa0 100644 --- a/lib/linux_ns.c +++ b/lib/linux_ns.c @@ -66,7 +66,10 @@ void linux_namespace_start(void *argv) { uwsgi_error("clone()"); exit(1); } - + if (mount(NULL, "/", NULL, MS_REC|MS_PRIVATE, NULL)) { + uwsgi_error("mount()"); + exit(1); + } // run the post-jail scripts if (setenv("UWSGI_JAIL_PID", uwsgi_num2str((int) pid), 1)) { uwsgi_error("setenv()"); @@ -173,6 +176,7 @@ void linux_namespace_jail() { uwsgi_log("remounting /proc\n"); if (mount("proc", "/proc", "proc", 0, NULL)) { uwsgi_error("mount()"); + exit(1); } struct uwsgi_string_list *usl = uwsgi.ns_keep_mount;