unset LD_PRELOAD in su because magist 16.4 is 32 bit only
[termux-packages] / packages / termux-tools / su
index bffa122..5bfd6af 100755 (executable)
@@ -1,11 +1,18 @@
-#!/bin/sh
+#!/data/data/com.termux/files/usr/bin/sh
 
-if [ -x /system/xbin/su ]; then
-       /system/xbin/su $@
-else
-       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
-fi
+unset LD_LIBRARY_PATH LD_PRELOAD
+
+for p in /system/xbin/su /system/bin/su /su/bin/su /sbin/su /magisk/.core/bin/su
+do
+       if [ -x $p ]; then
+               # The su tool may require programs in PATH:
+               PATH=/sbin/su:/su/bin:/su/xbin:/system/bin:/system/xbin \
+                       exec $p "$@"
+       fi
+done
+
+echo "No su program found 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