[tor-commits] [orbot/master] make sure to use the request shell for exec()

n8fr8 at torproject.org n8fr8 at torproject.org
Fri Jul 5 12:40:01 UTC 2019


commit 553528cbbe11790bcf4c3813e154e4a329e15ca5
Author: n8fr8 <nathan at guardianproject.info>
Date:   Wed Jun 5 14:50:38 2019 -0400

    make sure to use the request shell for exec()
---
 .../android/service/util/CustomShell.java          | 27 +---------------------
 1 file changed, 1 insertion(+), 26 deletions(-)

diff --git a/orbotservice/src/main/java/org/torproject/android/service/util/CustomShell.java b/orbotservice/src/main/java/org/torproject/android/service/util/CustomShell.java
index b959405d..f5d4c921 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/util/CustomShell.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/util/CustomShell.java
@@ -36,10 +36,9 @@ public class CustomShell extends Shell {
             if (env != null && (!env.isEmpty()))
                 builder.environment().putAll(env);
 
-            builder.command("/system/bin/sh", "-c", command);
+            builder.command("/system/bin/" + shell, "-c", command);
             Process process = builder.start();
 
-         //   DataOutputStream stdin = new DataOutputStream(process.getOutputStream());
             StreamGobbler stdoutGobbler = null;
             StreamGobbler stderrGobbler = null;
 
@@ -52,30 +51,6 @@ public class CustomShell extends Shell {
                 stderrGobbler.start();
             }
 
-            /**
-
-            try {
-                for (String write : commands) {
-                    stdin.write((write + " &\n").getBytes("UTF-8"));
-                    stdin.flush();
-                }
-
-                if (waitFor)
-                    stdin.write("exit\n".getBytes("UTF-8"));
-
-                stdin.flush();
-            } catch (IOException e) {
-                //noinspection StatementWithEmptyBody
-                if (e.getMessage().contains("EPIPE")) {
-                    // method most horrid to catch broken pipe, in which case we do nothing. the command is not a shell, the
-                    // shell closed stdin, the script already contained the exit command, etc. these cases we want the output
-                    // instead of returning null
-                } else {
-                    // other issues we don't know how to handle, leads to returning null
-                    throw e;
-                }
-            }**/
-
             // wait for our process to finish, while we gobble away in the background
             if (waitFor)
                 exitCode = process.waitFor();





More information about the tor-commits mailing list