Last active
October 16, 2021 05:26
-
-
Save kennethho/bc7502dcf6c0b4a53ef85758f797fc8b to your computer and use it in GitHub Desktop.
Sudo for Termux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/data/data/com.termux/files/usr/bin/bash | |
#set -x | |
SUDO_SH=/data/data/com.termux/files/usr/bin/sh | |
QUOTED_SUDO_ARGS=$(printf '%q' $"$(printf '%q ' "$@")") | |
#QUOTED_SUDO_ARGS=$(printf '%q ' \"$@\") | |
printf '%s\n' "$QUOTED_SUDO_ARGS" | |
SU_C_ARGS=("LD_LIBRARY_PATH=$PREFIX/lib" "$SUDO_SH" "-c" "$QUOTED_SUDO_ARGS") | |
for su in /system/xbin/su /su/bin/su | |
do | |
if [ -x $su ]; then | |
# The su tool may require programs in PATH: | |
PATH=$PATH:/su/bin:/su/xbin:/system/bin:/system/xbin \ | |
exec $su \ | |
--preserve-environment \ | |
-c "${SU_C_ARGS[@]}" | |
fi | |
done | |
echo "There is no su program on this device. Termux" | |
echo "does not supply tools for rooting, see e.g." | |
echo "http://www.androidcentral.com/root for" | |
echo "information about rooting Android." | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't know why they write that at the bottom. Do they not realize that the command
sudo bash
is the same thing assu
.Thank goodness, I don't think having to deal with running sh from that deep-a**
bin
directory I would be worth it. Even for root privilege.. every single time you type the command, you'd have to type that super long string first. You could try to build your own path variable, but you would probably fill up the phones storage with ANSI character codes before it finished writing! XD