aboutsummaryrefslogtreecommitdiff
path: root/infra/base-images/base-runner/run_minijail
diff options
context:
space:
mode:
authorOliver Chang <ochang@chromium.org>2017-10-16 15:54:58 -0700
committerOliver Chang <ochang@chromium.org>2017-10-16 15:54:58 -0700
commitfa41e6a94974a6f4607d8f8059c47a5f897590f5 (patch)
tree11e4f7e65beff9ca9bfcf2d2d765be4b232b96f5 /infra/base-images/base-runner/run_minijail
parentce51583db62df091cdef9c9afe0e08167566cc47 (diff)
downloadoss-fuzz-fa41e6a94974a6f4607d8f8059c47a5f897590f5.tar.gz
Add script for testing sandbox.
Diffstat (limited to 'infra/base-images/base-runner/run_minijail')
-rwxr-xr-xinfra/base-images/base-runner/run_minijail46
1 files changed, 46 insertions, 0 deletions
diff --git a/infra/base-images/base-runner/run_minijail b/infra/base-images/base-runner/run_minijail
new file mode 100755
index 000000000..856105980
--- /dev/null
+++ b/infra/base-images/base-runner/run_minijail
@@ -0,0 +1,46 @@
+#!/bin/bash -eu
+# Copyright 2017 Google Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+################################################################################
+
+rm -rf /tmp/chroot
+mkdir /tmp/chroot
+
+mkdir /tmp/chroot/lib
+mkdir /tmp/chroot/lib64
+
+mkdir /tmp/chroot/usr
+mkdir /tmp/chroot/usr/lib
+
+mkdir /tmp/chroot/dev
+mknod -m 666 /tmp/chroot/dev/null c 1 3
+mknod -m 666 /tmp/chroot/dev/urandom c 1 9
+
+mkdir /tmp/chroot/proc
+mkdir /tmp/chroot/tmp
+
+mkdir /tmp/chroot/bin
+cp /bin/sh /tmp/chroot/bin/sh
+cp $(which llvm-symbolizer) /tmp/chroot/bin/llvm-symbolizer
+
+EXE_DIR=$(dirname $(readlink -f $1))
+mkdir -p /tmp/chroot/$EXE_DIR
+
+minijail0 -U -m "0 $UID 1" -T static \
+ -c 0 -n -e -v -p -l -I \
+ -k proc,/proc,proc,1 -P /tmp/chroot \
+ -b /lib,/lib,0 -b /lib64,/lib64,0 -b /usr/lib,/usr/lib,0 \
+ -b /tmp,/tmp,1 \
+ -b $EXE_DIR,$EXE_DIR,0 $@