use proot to support Android 8

runshell: Use proot when running on Android, to work around Android 8's
ill-advised seccomp filtering of system calls, including ones crucial for
reliable thread locking. (This will only work with termux's version of
proot.)

See https://github.com/termux/termux-packages/issues/420#issuecomment-386636938

This commit was sponsored by andrea rota.
This commit is contained in:
Joey Hess 2018-05-05 08:55:50 -04:00
parent d1961e4498
commit 71f450f677
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 35 additions and 6 deletions

View file

@ -37,6 +37,8 @@ if echo "$base" | grep -q '[:;]'; then
rm -rf "$tbase"
}
trap cleanuptbase EXIT
else
tbase=""
fi
# Set this variable when using this script inside a package of git-annex,
@ -153,6 +155,7 @@ for localeenv in "$LANG" "$LANGUAGE" "$LC_CTYPE" "$LC_NUMERIC" "$LC_TIME" \
fi
done
useproot=""
case "$os" in
# Make this bundle work well on Android.
Android)
@ -169,6 +172,10 @@ case "$os" in
fi
fi
# Work around Android 8's seccomp filtering of some crucial
# system calls, using termux's version of proot.
useproot=1
# Store ssh connection caching sockets outside of sdcard.
GIT_ANNEX_TMP_DIR="$TMPDIR"
export GIT_ANNEX_TMP_DIR
@ -187,12 +194,21 @@ esac
if [ "$1" ]; then
cmd="$1"
shift 1
if [ -z "$tbase" ]; then
exec "$cmd" "$@"
else
cmd=sh
fi
if [ -z "$tbase" ]; then
if [ "$useproot" ]; then
exec proot "$cmd" "$@"
else
# allow EXIT trap to cleanup
"$cmd" "$@"
exec "$cmd" "$@"
fi
else
sh
# allow EXIT trap to cleanup
if [ "$useproot" ]; then
proot "$cmd" "$@"
else
"$cmd" "$@"
fi
fi