Skip to content

Commit

Permalink
Fix termux-reset
Browse files Browse the repository at this point in the history
The TMPDIR was being automatically cleared and recreated even if it didn't already exist when TermuxService was stopped. This left an empty TMPDIR in the PREFIX directory when termux-reset was run and on termux restart the bootstrap wasn't installed again because PREFIX directory already existed. This resulted in a broken environment since no binaries/libs existed under PREFIX and /system/bin/sh was loaded.

This issue was created due to v0.109.
  • Loading branch information
agnostic-apollo committed Apr 20, 2021
1 parent a6ae656 commit d6eb5e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/termux/app/TermuxService.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
public void onDestroy() {
Logger.logVerbose(LOG_TAG, "onDestroy");

ShellUtils.clearTermuxTMPDIR(this);
ShellUtils.clearTermuxTMPDIR(this, true);

actionReleaseWakeLock(false);
if (!mWantsToStop)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ public static String getExecutableBasename(String executable) {
return (lastSlash == -1) ? executable : executable.substring(lastSlash + 1);
}

public static void clearTermuxTMPDIR(Context context) {
public static void clearTermuxTMPDIR(Context context, boolean onlyIfExists) {
if(onlyIfExists && !FileUtils.directoryFileExists(TermuxConstants.TERMUX_TMP_PREFIX_DIR_PATH, false))
return;

String errmsg;
errmsg = FileUtils.clearDirectory(context, "$TMPDIR", FileUtils.getCanonicalPath(TermuxConstants.TERMUX_TMP_PREFIX_DIR_PATH, null, false));
if (errmsg != null) {
Expand Down

0 comments on commit d6eb5e3

Please sign in to comment.