Attempts to deduce if the shell command refers to a su shell @param shell Shell command to run @return Shell command appears to be su
(String shell)
| 535 | * @return Shell command appears to be su |
| 536 | */ |
| 537 | @AnyThread |
| 538 | public static boolean isSU(String shell) { |
| 539 | // Strip parameters |
| 540 | int pos = shell.indexOf(' '); |
| 541 | if (pos >= 0) { |
| 542 | shell = shell.substring(0, pos); |
| 543 | } |
| 544 | |
| 545 | // Strip path |
| 546 | pos = shell.lastIndexOf('/'); |
| 547 | if (pos >= 0) { |
| 548 | shell = shell.substring(pos + 1); |
| 549 | } |
| 550 | |
| 551 | return shell.toLowerCase(Locale.ENGLISH).equals("su"); |
| 552 | } |
| 553 | |
| 554 | /** |
| 555 | * Constructs a shell command to start a su shell using the supplied uid |
no outgoing calls
no test coverage detected