Don't die() on bind mounts.
By the time we get to the removed lines, |mounts_head| will be valid
in the parent (Minijail) process, but |flags.chroot| and
|flags.pivot_root| will have been cleared by minijail_preexec().
The removed lines were then incorrectly aborting the process too early.
The flags *will* be set in the minijail struct used by the
child (jailed) process, so the bind mounts will happen correctly.
A follow-up CL will make sure |mounts_head| is never valid when
both flags are cleared, so that we can correctly check for this.
While in there, fix a comment and an info() message.
security_Minijail0 now passes.
Bug: 25368607
Change-Id: I5ac85ee62560ba8957bdab3fc84689ed06d106f0
diff --git a/Android.mk b/Android.mk
index 186e569..5cd0499 100644
--- a/Android.mk
+++ b/Android.mk
@@ -45,7 +45,7 @@
generated_sources_dir := $(local-generated-sources-dir)
my_gen := $(generated_sources_dir)/$(TARGET_ARCH)/libsyscalls.c
-# We need the quotes so the shell script treat them as one argument.
+# We need the quotes so the shell script treats the following as one argument.
my_cc := "$(lastword $(CLANG)) \
$(addprefix -isystem ,$(TARGET_C_INCLUDES)) \
$(CLANG_TARGET_GLOBAL_CFLAGS)"
diff --git a/libminijail.c b/libminijail.c
index 0806d17..2164186 100644
--- a/libminijail.c
+++ b/libminijail.c
@@ -569,7 +569,7 @@
goto error;
m->flags = flags;
- info("mount %s -> %s type %s", src, dest, type);
+ info("mount %s -> %s type '%s'", src, dest, type);
/*
* Force vfs namespacing so the mounts don't leak out into the
@@ -1344,9 +1344,6 @@
pdie("unshare(net)");
}
- if (j->mounts_head && !(j->flags.chroot || j->flags.pivot_root))
- die("can't bind-mount without chroot or pivot_root");
-
if (j->flags.chroot && enter_chroot(j))
pdie("chroot");