From 17382fb190bbdf88352bd905ce34fb895f1d68fe Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Sun, 20 Mar 2016 22:17:21 +0100 Subject: [PATCH] Do not have /system/bin in the PATH By appending the old system PATH environment variable to the paths setup by Termux system binaries are found as a fallback. This causes problems with system binaries not working (due to LD_LIBRARY_PATH) and causing a lot of confusion for new users when e.g. an Android system provides a system version of e.g. curl, ssh and other programs. It's better for these users to be prompted to install the proper Termux package, and advanced users can still add /system/bin to the PATH themselves. Certain programs such as 'am' and 'pm' are already setup in $PREFIX/bin to clear LD_LIBRARY_PATH and launch the binaries in /system/bin - if there are some more popular ones they could be added in the same way. --- app/src/main/java/com/termux/app/TermuxService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/termux/app/TermuxService.java b/app/src/main/java/com/termux/app/TermuxService.java index 8cc0d310..d96d3f0a 100644 --- a/app/src/main/java/com/termux/app/TermuxService.java +++ b/app/src/main/java/com/termux/app/TermuxService.java @@ -243,13 +243,14 @@ public final class TermuxService extends Service implements SessionChangedCallba final String androidDataEnv = "ANDROID_DATA=" + System.getenv("ANDROID_DATA"); String[] env; if (failSafe) { + // Keep the default path so that system binaries can be used in the failsafe session. final String pathEnv = "PATH=" + System.getenv("PATH"); env = new String[] { termEnv, homeEnv, prefixEnv, androidRootEnv, androidDataEnv, pathEnv }; } else { final String ps1Env = "PS1=$ "; final String ldEnv = "LD_LIBRARY_PATH=" + PREFIX_PATH + "/lib"; final String langEnv = "LANG=en_US.UTF-8"; - final String pathEnv = "PATH=" + PREFIX_PATH + "/bin:" + PREFIX_PATH + "/bin/applets:" + System.getenv("PATH"); + final String pathEnv = "PATH=" + PREFIX_PATH + "/bin:" + PREFIX_PATH + "/bin/applets"; final String pwdEnv = "PWD=" + cwd; env = new String[] { termEnv, homeEnv, prefixEnv, ps1Env, ldEnv, langEnv, pathEnv, pwdEnv, androidRootEnv, androidDataEnv };