minijail: add minijail_run_pid_pipes_no_preload() API function
Add minijail_run_pid_pipes_no_preload() to the minijail API.
This method is equivalent to minijail_run_pid_pipes(), except
that LD_PRELOAD is not used. This function needs to be called
on Android.
BUG: 24577038
TEST: unit tests pass.
TEST: manual test on minijail'd binary passes.
Change-Id: I8067eee689c407501b18324fc378121ef28422fe
diff --git a/libminijail.c b/libminijail.c
index 2497115..92fc599 100644
--- a/libminijail.c
+++ b/libminijail.c
@@ -1259,6 +1259,14 @@
false);
}
+int API minijail_run_pid_pipes_no_preload(struct minijail *j,
+ const char *filename, char *const argv[],
+ pid_t *pchild_pid,
+ int *pstdin_fd, int *pstdout_fd, int *pstderr_fd) {
+ return minijail_run_internal(j, filename, argv, pchild_pid,
+ pstdin_fd, pstdout_fd, pstderr_fd, false);
+}
+
int minijail_run_internal(struct minijail *j, const char *filename,
char *const argv[], pid_t *pchild_pid,
int *pstdin_fd, int *pstdout_fd, int *pstderr_fd,
diff --git a/libminijail.h b/libminijail.h
index d6c3c42..bdf08eb 100644
--- a/libminijail.h
+++ b/libminijail.h
@@ -167,6 +167,20 @@
char *const argv[], pid_t *pchild_pid,
int *pstdin_fd, int *pstdout_fd, int *pstderr_fd);
+/* Run the specified command in the given minijail, execve(2)-style.
+ * Update |*pchild_pid| with the pid of the child.
+ * Update |*pstdin_fd| with a fd that allows writing to the child's
+ * standard input.
+ * Update |*pstdout_fd| with a fd that allows reading from the child's
+ * standard output.
+ * Update |*pstderr_fd| with a fd that allows reading from the child's
+ * standard error.
+ * Used with static binaries, or on systems without support for LD_PRELOAD.
+ */
+int minijail_run_pid_pipes_no_preload(struct minijail *j, const char *filename,
+ char *const argv[], pid_t *pchild_pid,
+ int *pstdin_fd, int *pstdout_fd, int *pstderr_fd);
+
/* Kill the specified minijail. The minijail must have been created with pid
* namespacing; if it was, all processes inside it are atomically killed.
*/