In case there's no CLONE_NEWNS, just chroot()
authorJagger <robert@swiecki.net>
Sun, 16 Aug 2015 08:55:14 +0000 (10:55 +0200)
committerJagger <robert@swiecki.net>
Sun, 16 Aug 2015 08:55:14 +0000 (10:55 +0200)
contain.c

index 39ecde33a93338e162dec8ff42f7e59dc5c56f2b..dd9e6a18167baf7f748967b975affc77f4b46b1a 100644 (file)
--- a/contain.c
+++ b/contain.c
@@ -305,6 +305,19 @@ static bool containMountProc(struct nsjconf_t *nsjconf, const char *newrootdir)
 
 bool containMountFS(struct nsjconf_t * nsjconf)
 {
+       if (nsjconf->clone_newns == false) {
+               if (chroot(nsjconf->chroot) == -1) {
+                       PLOG_E("chroot('%s')", nsjconf->chroot) {
+                               return false;
+                       }
+               }
+               if (chdir("/") == -1) {
+                       PLOG_E("chdir('/')");
+                       return false;
+               }
+               return true;
+       }
+
        const char *destdir = "/tmp";
        if (mount("none", destdir, "tmpfs", 0, NULL) == -1) {
                PLOG_E("mount('%s', 'tmpfs'", destdir);