Feature: Load execve() hook on startup.

This commit is contained in:
zt515
2017-10-07 22:59:33 +08:00
parent 8e00140c8a
commit b0cfb4d684
3 changed files with 7 additions and 2 deletions

View File

@ -12,7 +12,7 @@ static const char *rewrite_executable(const char *filename, char *buffer, int bu
if (bin_match == filename || bin_match == (filename + 4)) {
// We have either found "/bin/" at the start of the string or at
// "/xxx/bin/". Take the path after that.
strncpy(buffer + 36, bin_match + 5, buffer_len - 37);
strncpy(buffer + 36, bin_match + 5, (size_t) (buffer_len - 37));
filename = buffer;
}
return filename;

View File

@ -6,6 +6,7 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import io.neoterm.component.NeoInitializer
import io.neoterm.frontend.logging.NLog
import io.neoterm.frontend.preference.NeoPreference
import io.neoterm.utils.CrashHandler

View File

@ -181,9 +181,13 @@ open class ShellTermSession private constructor(shellPath: String, cwd: String,
val originPathEnv = "__NEOTERM_ORIGIN_PATH=" + System.getenv("PATH")
val originLdEnv = "__NEOTERM_ORIGIN_LD_LIBRARY_PATH=" + System.getenv("LD_LIBRARY_PATH")
// execve(2) wrapper to avoid incorrect shebang
val ldPreloadEnv= "LD_PRELOAD=${App.get().applicationInfo.nativeLibraryDir}/libnexec.so"
arrayOf(termEnv, homeEnv, ps1Env, ldEnv, langEnv, pathEnv, pwdEnv,
androidRootEnv, androidDataEnv, externalStorageEnv,
tmpdirEnv, neotermIdEnv, originPathEnv, originLdEnv)
tmpdirEnv, neotermIdEnv, originPathEnv, originLdEnv,
ldPreloadEnv)
}
}