build/qemu-wrap

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rwxr-xr-x

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 #!/bin/bash
michael@0 2 # this script creates a wrapper shell script for an executable. The idea is the actual executable cannot be
michael@0 3 # executed natively (it was cross compiled), but we want to run tests natively. Running this script
michael@0 4 # as part of the compilation process will move the non-native executable to a new location, and replace it
michael@0 5 # with a script that will run it under qemu.
michael@0 6 while [[ -n $1 ]]; do
michael@0 7 case $1 in
michael@0 8 --qemu) QEMU="$2"; shift 2;;
michael@0 9 --libdir) LIBDIR="$2"; shift 2;;
michael@0 10 --ld) LD="$2"; shift 2;;
michael@0 11 *) exe="$1"; shift;;
michael@0 12 esac
michael@0 13 done
michael@0 14 if [[ -z $LIBDIR ]]; then
michael@0 15 echo "You need to specify a directory for the cross libraries when you configure the shell"
michael@0 16 echo "You can do this with --with-cross-lib="
michael@0 17 exit 1
michael@0 18 fi
michael@0 19 LD=${LD:-$LIBDIR/ld-linux.so.3}
michael@0 20 mv $exe $exe.target
michael@0 21 # Just hardcode the path to the executable. It'll be pretty obvious if it is doing the wrong thing.
michael@0 22
michael@0 23 echo $'#!/bin/bash\n' $QEMU -E LD_LIBRARY_PATH="${LIBDIR}" "$LD" "$(readlink -f "$exe.target")" '"$@"' >"$exe"
michael@0 24 chmod +x $exe

mercurial