From dac85757b31a9dd0562115e0d97f5f1c98862a86 Mon Sep 17 00:00:00 2001 From: d8ahazard Date: Sun, 25 Sep 2016 02:16:10 -0500 Subject: [PATCH] Re-add busybox Add check for proper install, install if not. Needed for flashing zips. --- .../com/topjohnwu/magisk/SplashActivity.java | 18 ++++++++++++++++++ .../java/com/topjohnwu/magisk/utils/Utils.java | 11 +++++++++++ 2 files changed, 29 insertions(+) diff --git a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java index 7e7bd9901..eff4d3562 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java @@ -10,6 +10,7 @@ import android.support.v7.app.AppCompatActivity; import com.topjohnwu.magisk.services.MonitorService; import com.topjohnwu.magisk.utils.Async; import com.topjohnwu.magisk.utils.Logger; +import com.topjohnwu.magisk.utils.Shell; import com.topjohnwu.magisk.utils.Utils; import java.util.HashSet; @@ -64,6 +65,23 @@ public class SplashActivity extends AppCompatActivity { // Initialize + + if (Shell.rootAccess()) { + if (!Utils.busyboxInstalled()) { + String busybox = getApplicationContext().getApplicationInfo().nativeLibraryDir + "/libbusybox.so"; + Shell.su( + "rm -rf /data/busybox", + "mkdir -p /data/busybox", + "cp -af " + busybox + " /data/busybox/busybox", + "chmod 755 /data/busybox /data/busybox/busybox", + "chcon u:object_r:system_file:s0 /data/busybox /data/busybox/busybox", + "/data/busybox/busybox --install -s /data/busybox", + "rm -f /data/busybox/su", + "export PATH=/data/busybox:$PATH" + ); + } + } + new Async.CheckUpdates(this).execute(); new Async.LoadModules(this).execute(); new Async.LoadRepos(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java b/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java index 00d0261c9..fcb67ab9d 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java +++ b/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java @@ -91,6 +91,17 @@ public class Utils { return Boolean.parseBoolean(ret.get(0)); } + public static boolean busyboxInstalled() { + List ret; + String command = "if [ -d /data/busybox ]; then echo true; else echo false; fi"; + if (Shell.rootAccess()) { + ret = Shell.su(command); + } else { + ret = Shell.sh(command); + } + return Boolean.parseBoolean(ret.get(0)); + } + public static boolean rootEnabled() { List ret; String command = "if [ -z $(which su) ]; then echo false; else echo true; fi";