Add DEFAULT_PIVOT_ROOT var which can be changed at build time.
This allows the default pivot root included with the
minimalistic-mountns profile to be defined at build time. If it is not
set the original value /var/empty is used.
Bug: crbug.com/933582
Test: minijail builds successfully on both Android and CrOS
Change-Id: Ifa167d3d5d5725667b0d20ad47724af4abc24ae0
diff --git a/Android.bp b/Android.bp
index 7bce0f1..5cd7966 100644
--- a/Android.bp
+++ b/Android.bp
@@ -35,6 +35,7 @@
cflags: [
"-D_FILE_OFFSET_BITS=64",
"-DALLOW_DEBUG_LOGGING",
+ "-DDEFAULT_PIVOT_ROOT=\"/var/empty\"",
"-Wall",
"-Werror",
],
diff --git a/Makefile b/Makefile
index 9a13d8e..b2c5569 100644
--- a/Makefile
+++ b/Makefile
@@ -7,8 +7,12 @@
LIBDIR ?= /lib
PRELOADNAME = libminijailpreload.so
-PRELOADPATH = \"$(LIBDIR)/$(PRELOADNAME)\"
-CPPFLAGS += -DPRELOADPATH="$(PRELOADPATH)"
+PRELOADPATH = "$(LIBDIR)/$(PRELOADNAME)"
+CPPFLAGS += -DPRELOADPATH='$(PRELOADPATH)'
+
+# Defines the pivot root path used by the minimalistic-mountns profile.
+DEFAULT_PIVOT_ROOT ?= /var/empty
+CPPFLAGS += -DDEFAULT_PIVOT_ROOT='"$(DEFAULT_PIVOT_ROOT)"'
ifeq ($(USE_seccomp),no)
CPPFLAGS += -DUSE_SECCOMP_SOFTFAIL
diff --git a/minijail0_cli.c b/minijail0_cli.c
index 2106ccb..d5b09f7 100644
--- a/minijail0_cli.c
+++ b/minijail0_cli.c
@@ -385,7 +385,7 @@
*tmp_size = DEFAULT_TMP_SIZE;
}
minijail_remount_proc_readonly(j);
- use_pivot_root(j, "/var/empty", pivot_root, chroot);
+ use_pivot_root(j, DEFAULT_PIVOT_ROOT, pivot_root, chroot);
} else {
fprintf(stderr, "Unrecognized profile name '%s'\n", profile);
exit(1);