Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't enter in root environment #73

Open
ritcher opened this issue Oct 8, 2020 · 1 comment
Open

Can't enter in root environment #73

ritcher opened this issue Oct 8, 2020 · 1 comment

Comments

@ritcher
Copy link

ritcher commented Oct 8, 2020

There is the output I got:

$ tsu --dbg
+ shift
+ _TSU_CALL=tsu
+ [[ tsu == \s\u\d\o ]]
+ TERMUX_FS=/data/data/com.termux/files
+ TERMUX_PREFIX=/data/data/com.termux/files/usr
+ TERMUX_PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets
+ ROOT_HOME=/data/data/com.termux/files/home/.suroot
+ ANDROID_SYSPATHS=/system/bin:/system/xbin
+ EXTRA_SYSPATHS=/sbin:/sbin/bin
+ BB_MAGISK=/sbin/.magisk/busybox
+ log_DEBUG TSU_AS_SUDO
+ [[ '' == true ]]
+ log_DEBUG _TSU_AS_SUDO
+ [[ -z '' ]]
+ SWITCH_USER=
+ declare -A EXP_ENV
+ log_DEBUG _TSU_AS_SUDO
+ [[ '' == true ]]
+ root_shell_helper
+ log_DEBUG root_shell_helper
+ [[ -n '' ]]
+ log_DEBUG ALT_SHELL
+ [[ '' == \s\y\s\t\e\m ]]
+ [[ -n '' ]]
+ [[ -x /data/data/com.termux/files/home/.termux/shell ]]
++ readlink -f -- /data/data/com.termux/files/home/.termux/shell
+ ROOT_SHELL=/data/data/com.termux/files/usr/bin/zsh
+ env_path_helper
+ log_DEBUG env_path_helper
+ log_DEBUG SWITCH_USER
+ [[ -z '' ]]
+ [[ -d /data/data/com.termux/files/home/.suroot ]]
+ NEW_HOME=/data/data/com.termux/files/home/.suroot
+ EXP_ENV[PREFIX]=/data/data/com.termux/files/usr
+ EXP_ENV[TMPDIR]=/data/data/com.termux/files/home/.suroot/.tmp
+ EXP_ENV[LD_PRELOAD]=/data/data/com.termux/files/usr/lib/libtermux-exec.so
+ log_DEBUG _TSU_AS_SUDO
+ [[ '' == true ]]
+ NEW_PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets
+ log_DEBUG LD_LIBRARY_PATH
+ [[ -n '' ]]
+ ASP=/system/bin:/system/xbin:/sbin:/sbin/bin
+ log_DEBUG PREPEND_SYSTEM_PATH
+ [[ -n '' ]]
+ NEW_PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin
+ EXP_ENV[PATH]=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin
+ EXP_ENV[HOME]=/data/data/com.termux/files/home/.suroot
+ EXP_ENV[TERM]=xterm-256color
+ [[ -z true ]]
+ set +x
+ STARTUP_SCRIPT=/data/data/com.termux/files/usr/bin/zsh
+ SU_BINARY_SEARCH=("/system/xbin/su" "/system/bin/su")
+ [[ -x /sbin ]]
+ SU_BINARY_SEARCH+=("/sbin/su" "/sbin/bin/su")
+ unset LD_LIBRARY_PATH
+ unset LD_PRELOAD
+ [[ -z '' ]]
++ /sbin/su -v
+ [[ 20.4:MAGISKSU == *\M\A\G\I\S\K\S\U ]]
+ su_args=("/sbin/su")
+ [[ -z '' ]]
+ su_cmdline='PATH=/sbin/.magisk/busybox '
+ [[ -n '' ]]
+ su_cmdline+='env -i  PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin  ANDROID_DATA=/data  TMPDIR=/data/data/com.termux/files/home/.suroot/.tmp  PREFIX=/data/data/com.termux/files/usr  TERM=xterm-256color  LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so  ANDROID_ROOT=/system  HOME=/data/data/com.termux/files/home/.suroot  /data/data/com.termux/files/usr/bin/zsh'
+ su_args+=("-c")
+ exec /sbin/su -c 'PATH=/sbin/.magisk/busybox env -i  PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin  ANDROID_DATA=/data  TMPDIR=/data/data/com.termux/files/home/.suroot/.tmp  PREFIX=/data/data/com.termux/files/usr  TERM=xterm-256color  LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so  ANDROID_ROOT=/system  HOME=/data/data/com.termux/files/home/.suroot  /data/data/com.termux/files/usr/bin/zsh'
/system/bin/sh: env: not found

Changing the env command call to /system/bin/env or /data/data/com.termux/files/usr/bin/coreutils --coreutils-prog=env solves the problem:

$ sed -i 's/env /\/system\/bin\/env /g' ../usr/bin/tsu
$ tsu --dbg
+ shift
+ _TSU_CALL=tsu
+ [[ tsu == \s\u\d\o ]]
+ TERMUX_FS=/data/data/com.termux/files
+ TERMUX_PREFIX=/data/data/com.termux/files/usr
+ TERMUX_PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets
+ ROOT_HOME=/data/data/com.termux/files/home/.suroot
+ ANDROID_SYSPATHS=/system/bin:/system/xbin
+ EXTRA_SYSPATHS=/sbin:/sbin/bin
+ BB_MAGISK=/sbin/.magisk/busybox
+ log_DEBUG TSU_AS_SUDO
+ [[ '' == true ]]
+ log_DEBUG _TSU_AS_SUDO
+ [[ -z '' ]]
+ SWITCH_USER=
+ declare -A EXP_ENV
+ log_DEBUG _TSU_AS_SUDO
+ [[ '' == true ]]
+ root_shell_helper
+ log_DEBUG root_shell_helper
+ [[ -n '' ]]
+ log_DEBUG ALT_SHELL
+ [[ '' == \s\y\s\t\e\m ]]
+ [[ -n '' ]]
+ [[ -x /data/data/com.termux/files/home/.termux/shell ]]
++ readlink -f -- /data/data/com.termux/files/home/.termux/shell
+ ROOT_SHELL=/data/data/com.termux/files/usr/bin/zsh
+ env_path_helper
+ log_DEBUG env_path_helper
+ log_DEBUG SWITCH_USER
+ [[ -z '' ]]
+ [[ -d /data/data/com.termux/files/home/.suroot ]]
+ NEW_HOME=/data/data/com.termux/files/home/.suroot
+ EXP_ENV[PREFIX]=/data/data/com.termux/files/usr
+ EXP_ENV[TMPDIR]=/data/data/com.termux/files/home/.suroot/.tmp
+ EXP_ENV[LD_PRELOAD]=/data/data/com.termux/files/usr/lib/libtermux-exec.so
+ log_DEBUG _TSU_AS_SUDO
+ [[ '' == true ]]
+ NEW_PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets
+ log_DEBUG LD_LIBRARY_PATH
+ [[ -n '' ]]
+ ASP=/system/bin:/system/xbin:/sbin:/sbin/bin
+ log_DEBUG PREPEND_SYSTEM_PATH
+ [[ -n '' ]]
+ NEW_PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin
+ EXP_ENV[PATH]=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin
+ EXP_ENV[HOME]=/data/data/com.termux/files/home/.suroot
+ EXP_ENV[TERM]=xterm-256color
+ [[ -z true ]]
+ set +x
+ STARTUP_SCRIPT=/data/data/com.termux/files/usr/bin/zsh
+ SU_BINARY_SEARCH=("/system/xbin/su" "/system/bin/su")
+ [[ -x /sbin ]]
+ SU_BINARY_SEARCH+=("/sbin/su" "/sbin/bin/su")
+ unset LD_LIBRARY_PATH
+ unset LD_PRELOAD
+ [[ -z '' ]]
++ /sbin/su -v
+ [[ 20.4:MAGISKSU == *\M\A\G\I\S\K\S\U ]]
+ su_args=("/sbin/su")
+ [[ -z '' ]]
+ su_cmdline='PATH=/sbin/.magisk/busybox '
+ [[ -n '' ]]
+ su_cmdline+='/system/bin/env -i  PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin  ANDROID_DATA=/data  TMPDIR=/data/data/com.termux/files/home/.suroot/.tmp  PREFIX=/data/data/com.termux/files/usr  TERM=xterm-256color  LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so  ANDROID_ROOT=/system  HOME=/data/data/com.termux/files/home/.suroot  /data/data/com.termux/files/usr/bin/zsh'
+ su_args+=("-c")
+ exec /sbin/su -c 'PATH=/sbin/.magisk/busybox /system/bin/env -i  PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin  ANDROID_DATA=/data  TMPDIR=/data/data/com.termux/files/home/.suroot/.tmp  PREFIX=/data/data/com.termux/files/usr  TERM=xterm-256color  LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so  ANDROID_ROOT=/system  HOME=/data/data/com.termux/files/home/.suroot  /data/data/com.termux/files/usr/bin/zsh'
# id
uid=0(root) gid=0(root) groups=0(root)
@sjevtic
Copy link

sjevtic commented Feb 17, 2021

The error means that /sbin/.magisk/busybox/env cannot be found, so check that Magisk Manager has completed setup.

Every time you wipe your /data partition you must actually open the Magisk Manager GUI, wait for the "additional setup required" prompt and complete the setup process including the subsequent reboot before trying tsu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants