jail: ensure mounts are not MS_SHARED to avoid pivot_root() failure
authorEtienne CHAMPETIER <champetier.etienne@gmail.com>
Sun, 29 May 2016 23:39:17 +0000 (23:39 +0000)
committerJohn Crispin <john@phrozen.org>
Wed, 1 Jun 2016 08:27:35 +0000 (10:27 +0200)
By default mounts are MS_PRIVATE (kernel default) but systemd
decided to make it MS_SHARED by default since v188
https://github.com/systemd/systemd/commit/b3ac5f8cb98757416d8660023d6564a7c411f0a0

This patch fixes ujail on systemd distro (useful for development at least).

Signed-off-by: Etienne CHAMPETIER <champetier.etienne@gmail.com>
jail/jail.c

index b3f27d3d715a9ee87e1f5b0342fc012c29c91163..e42525484779cefe341f2142d805810174370224 100644 (file)
@@ -129,6 +129,12 @@ static int build_jail_fs(void)
                return -1;
        }
 
+       /* oldroot can't be MS_SHARED else pivot_root() fails */
+       if (mount("none", "/", NULL, MS_REC|MS_PRIVATE, NULL)) {
+               ERROR("private mount failed %s\n", strerror(errno));
+               return -1;
+       }
+
        if (mount("tmpfs", jail_root, "tmpfs", MS_NOATIME, "mode=0755")) {
                ERROR("tmpfs mount failed %s\n", strerror(errno));
                return -1;