minijail: Refactor dynamic and static code paths.

This CL uses the same code path for both dynamic and static binaries.
This way we avoid duplicating code, or forgetting to add functionality
to either of the paths.

BUG=chromium:537667
TEST=security_Minijail0 passes.

Change-Id: Ia484180a041dad3c302c3c8ce8bfd5b41d758ccb
Reviewed-on: https://chromium-review.googlesource.com/303380
Commit-Ready: Jorge Lucangeli Obes <jorgelo@chromium.org>
Tested-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
diff --git a/minijail0.c b/minijail0.c
index 4c5f9d6..2ded926 100644
--- a/minijail0.c
+++ b/minijail0.c
@@ -144,7 +144,8 @@
 	const char *filter_path;
 	if (argc > 1 && argv[1][0] != '-')
 		return 1;
-	while ((opt = getopt(argc, argv, "u:g:sS:c:C:P:b:V:f:m:M:vrGhHinpLetIU")) != -1) {
+	while ((opt = getopt(argc, argv,
+			     "u:g:sS:c:C:P:b:V:f:m:M:vrGhHinpLetIU")) != -1) {
 		switch (opt) {
 		case 'u':
 			set_user(j, optarg);
@@ -309,8 +310,11 @@
 	/* Check if target is statically or dynamically linked. */
 	elftype = get_elf_linkage(argv[0]);
 	if (elftype == ELFSTATIC) {
-		/* Target binary is static. */
-		minijail_run_static(j, argv[0], argv);
+		/*
+		 * Target binary is statically linked so we cannot use
+		 * libminijailpreload.so.
+		 */
+		minijail_run_no_preload(j, argv[0], argv);
 	} else if (elftype == ELFDYNAMIC) {
 		/*
 		 * Target binary is dynamically linked so we can