From ce3156c9fe733c52e60cbe20fcfccb8cf59f26bc Mon Sep 17 00:00:00 2001 From: goapunk <noobie@goapunks.net> Date: Fri, 17 Mar 2017 10:10:54 +0100 Subject: [PATCH] Use ProcessBuilder instead of Runtime to start tor * ProcessBuilder copies the ENV from the current proc and preserves ANDROID_ROOT and ANDROID_DATA Signed-off-by: goapunk <noobie@goapunks.net> --- .../briarproject/bramble/plugin/tor/TorPlugin.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/bramble-android/src/main/java/org/briarproject/bramble/plugin/tor/TorPlugin.java b/bramble-android/src/main/java/org/briarproject/bramble/plugin/tor/TorPlugin.java index 7d12208e2e..90c7535b48 100644 --- a/bramble-android/src/main/java/org/briarproject/bramble/plugin/tor/TorPlugin.java +++ b/bramble-android/src/main/java/org/briarproject/bramble/plugin/tor/TorPlugin.java @@ -182,15 +182,14 @@ class TorPlugin implements DuplexPlugin, EventHandler, EventListener { String torPath = torFile.getAbsolutePath(); String configPath = configFile.getAbsolutePath(); String pid = String.valueOf(android.os.Process.myPid()); - String[] cmd = {torPath, "-f", configPath, OWNER, pid}; - String[] env = { - "HOME=" + torDirectory.getAbsolutePath(), - "ANDROID_ROOT=/system", - "ANDROID_DATA=/data" - }; Process torProcess; + ProcessBuilder pb = + new ProcessBuilder(torPath, "-f", configPath, OWNER, pid); + Map<String, String> env = pb.environment(); + env.put("HOME", torDirectory.getAbsolutePath()); + pb.directory(torDirectory); try { - torProcess = Runtime.getRuntime().exec(cmd, env, torDirectory); + torProcess = pb.start(); } catch (SecurityException | IOException e) { throw new PluginException(e); } -- GitLab