MCPcopy Index your code
hub / github.com/cSploit/android / startCoreDaemon

Method startCoreDaemon

cSploit/src/org/csploit/android/core/System.java:230–292  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

228 }
229
230 private static void startCoreDaemon() throws SuException, DaemonException {
231 boolean access_granted = false;
232 DataOutputStream writer = null;
233 BufferedReader reader = null;
234 String line;
235 int ret = -1;
236
237 try {
238 Process shell = Runtime.getRuntime().exec("su");
239 writer = new DataOutputStream(shell.getOutputStream());
240 String cmd;
241
242 cmd = String.format("{ echo 'ACCESS GRANTED' >&2; cd '%s' && exec ./start_daemon.sh ;} || exit 1\n",
243 System.getCorePath());
244
245 writer.write(cmd.getBytes());
246 writer.flush();
247
248 ret = shell.waitFor();
249
250 if(ret != 0) {
251 reader = new BufferedReader(new InputStreamReader(shell.getErrorStream()));
252
253 while((line = reader.readLine()) != null) {
254 if(line.equals("ACCESS GRANTED")) {
255 access_granted = true;
256 Logger.debug("'ACCESS GRANTED' found");
257 } else
258 Logger.warning("STDERR: " + line);
259 }
260 } else
261 access_granted = true;
262
263 } catch ( IOException e) {
264 // command "su" not found or cannot write to it's stdin
265 Logger.error(e.getMessage());
266 } catch (InterruptedException e) {
267 // interrupted while waiting for shell exit value
268 Logger.error(e.getMessage());
269 } finally {
270 if(writer != null)
271 try { writer.close(); } catch (IOException ignored) {}
272 if(reader != null)
273 try { reader.close(); } catch (IOException ignored) {}
274 }
275
276 mKnownIssues.fromFile(String.format("%s/issues", getCorePath()));
277
278 if(!access_granted)
279 throw new SuException();
280
281 if(ret != 0) {
282 File log = new File(System.getCorePath(), "cSploitd.log");
283 DaemonException daemonException = new DaemonException("core daemon returned " + ret);
284 if(log.exists() && log.canRead()) {
285 ACRAConfiguration conf = ACRA.getConfig();
286 conf.setApplicationLogFile(log.getAbsolutePath());
287 ACRA.setConfig(conf);

Callers 1

initCoreMethod · 0.95

Calls 8

getCorePathMethod · 0.95
debugMethod · 0.95
warningMethod · 0.95
errorMethod · 0.95
formatMethod · 0.80
fromFileMethod · 0.80
execMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected