Respect failsafe sessions in ACTION_EXECUTE

This commit is contained in:
Fredrik Fornwall
2019-06-09 19:59:58 +02:00
parent 9f2d887ca0
commit e502b9169f
2 changed files with 10 additions and 8 deletions

View File

@@ -590,8 +590,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
new AlertDialog.Builder(this).setTitle(R.string.max_terminals_reached_title).setMessage(R.string.max_terminals_reached_message)
.setPositiveButton(android.R.string.ok, null).show();
} else {
String executablePath = (failSafe ? "/system/bin/sh" : null);
TerminalSession newSession = mTermService.createTermSession(executablePath, null, null, failSafe);
TerminalSession newSession = mTermService.createTermSession(null, null, null, failSafe);
if (sessionName != null) {
newSession.mSessionName = sessionName;
}

View File

@@ -136,7 +136,8 @@ public final class TermuxService extends Service implements SessionChangedCallba
mBackgroundTasks.add(task);
updateNotification();
} else {
TerminalSession newSession = createTermSession(executablePath, arguments, cwd, false);
boolean failsafe = intent.getBooleanExtra(TermuxActivity.TERMUX_FAILSAFE_SESSION_ACTION, false);
TerminalSession newSession = createTermSession(executablePath, arguments, cwd, failsafe);
// Transform executable path to session name, e.g. "/bin/do-something.sh" => "do something.sh".
if (executablePath != null) {
@@ -271,6 +272,7 @@ public final class TermuxService extends Service implements SessionChangedCallba
boolean isLoginShell = false;
if (executablePath == null) {
if (!failSafe) {
for (String shellBinary : new String[]{"login", "bash", "zsh"}) {
File shellFile = new File(PREFIX_PATH + "/bin/" + shellBinary);
if (shellFile.canExecute()) {
@@ -278,6 +280,7 @@ public final class TermuxService extends Service implements SessionChangedCallba
break;
}
}
}
if (executablePath == null) {
// Fall back to system shell as last resort: