diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/root/MiscCommands.kt b/mobile/src/main/java/be/mygod/vpnhotspot/root/MiscCommands.kt index c3339e2c..6ef4b858 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/root/MiscCommands.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/root/MiscCommands.kt @@ -19,12 +19,14 @@ import java.io.FileOutputStream import java.io.InterruptedIOException import java.util.concurrent.Executor +val SHELL = System.getenv("SHELL") ?: "sh" + @Parcelize class Dump(val path: String, val cacheDir: File = app.deviceStorage.codeCacheDir) : RootCommandNoResult { @Suppress("BlockingMethodInNonBlockingContext") override suspend fun execute() = withContext(Dispatchers.IO) { FileOutputStream(path, true).use { out -> - val process = ProcessBuilder("sh").redirectErrorStream(true).start() + val process = ProcessBuilder(SHELL).redirectErrorStream(true).start() process.outputStream.bufferedWriter().use { commands -> // https://android.googlesource.com/platform/external/iptables/+/android-7.0.0_r1/iptables/Android.mk#34 val iptablesSave = if (Build.VERSION.SDK_INT < 24) File(cacheDir, "iptables-save").absolutePath.also { diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/root/RoutingCommands.kt b/mobile/src/main/java/be/mygod/vpnhotspot/root/RoutingCommands.kt index c90ad964..cf5e0b32 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/root/RoutingCommands.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/root/RoutingCommands.kt @@ -16,7 +16,7 @@ object RoutingCommands { class Clean : RootCommandOneWay { @Suppress("BlockingMethodInNonBlockingContext") override suspend fun execute() = withContext(Dispatchers.IO) { - val process = ProcessBuilder("sh").redirectErrorStream(true).start() + val process = ProcessBuilder(SHELL).redirectErrorStream(true).start() process.outputStream.bufferedWriter().use(Routing.Companion::appendCleanCommands) when (val code = process.waitFor()) { 0 -> { } @@ -48,6 +48,7 @@ object RoutingCommands { class Process(val command: List, private val redirect: Boolean = false) : RootCommand { @Suppress("BlockingMethodInNonBlockingContext") override suspend fun execute() = withContext(Dispatchers.IO) { + val command = if (command[0] == "sh") listOf(SHELL) + command.drop(1) else command val process = ProcessBuilder(command).redirectErrorStream(redirect).start() coroutineScope { val output = async { process.inputStream.bufferedReader().readText() }