mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-04 22:47:38 +00:00
Fix root shell racing condition
This commit is contained in:
parent
62523c815e
commit
ff6bae936d
@ -46,7 +46,7 @@ public class Async {
|
|||||||
String busybox = mContext.getApplicationInfo().dataDir + "/lib/libbusybox.so";
|
String busybox = mContext.getApplicationInfo().dataDir + "/lib/libbusybox.so";
|
||||||
String zip = mContext.getApplicationInfo().dataDir + "/lib/libzip.so";
|
String zip = mContext.getApplicationInfo().dataDir + "/lib/libzip.so";
|
||||||
if (Shell.rootAccess()) {
|
if (Shell.rootAccess()) {
|
||||||
if (!Utils.itemExist(toolPath)) {
|
if (!Utils.itemExist(false, toolPath)) {
|
||||||
Shell.sh(
|
Shell.sh(
|
||||||
"rm -rf " + toolPath,
|
"rm -rf " + toolPath,
|
||||||
"mkdir " + toolPath,
|
"mkdir " + toolPath,
|
||||||
|
@ -65,14 +65,16 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean itemExist(String path) {
|
public static boolean itemExist(String path) {
|
||||||
List<String> ret;
|
return itemExist(true, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean itemExist(boolean root, String path) {
|
||||||
String command = "if [ -e " + path + " ]; then echo true; else echo false; fi";
|
String command = "if [ -e " + path + " ]; then echo true; else echo false; fi";
|
||||||
if (Shell.rootAccess()) {
|
if (Shell.rootAccess() && root) {
|
||||||
ret = Shell.su(command);
|
return Boolean.parseBoolean(Shell.su(command).get(0));
|
||||||
} else {
|
} else {
|
||||||
ret = Shell.sh(command);
|
return new File(path).exists();
|
||||||
}
|
}
|
||||||
return Boolean.parseBoolean(ret.get(0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean commandExists(String s) {
|
public static boolean commandExists(String s) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user