mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 18:45:28 +00:00
Always use global mount namespace
This commit is contained in:
parent
337b4c4268
commit
3cc458abd9
@ -29,6 +29,17 @@ public class Shell {
|
|||||||
|
|
||||||
private boolean isValid;
|
private boolean isValid;
|
||||||
|
|
||||||
|
private void testRootShell(DataOutputStream in, DataInputStream out) throws IOException {
|
||||||
|
in.write(("id\n").getBytes("UTF-8"));
|
||||||
|
in.flush();
|
||||||
|
String s = new BufferedReader(new InputStreamReader(out)).readLine();
|
||||||
|
if (TextUtils.isEmpty(s) || !s.contains("uid=0")) {
|
||||||
|
in.close();
|
||||||
|
out.close();
|
||||||
|
throw new IOException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Shell() {
|
private Shell() {
|
||||||
rootStatus = 1;
|
rootStatus = 1;
|
||||||
Process process = null;
|
Process process = null;
|
||||||
@ -36,45 +47,36 @@ public class Shell {
|
|||||||
DataInputStream out = null;
|
DataInputStream out = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
process = Runtime.getRuntime().exec("su");
|
// Try getting global namespace
|
||||||
|
process = Runtime.getRuntime().exec("su --mount-master");
|
||||||
in = new DataOutputStream(process.getOutputStream());
|
in = new DataOutputStream(process.getOutputStream());
|
||||||
out = new DataInputStream(process.getInputStream());
|
out = new DataInputStream(process.getInputStream());
|
||||||
|
testRootShell(in, out);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
rootStatus = 0;
|
// Feature not implemented, normal root shell
|
||||||
|
try {
|
||||||
|
process = Runtime.getRuntime().exec("su");
|
||||||
|
in = new DataOutputStream(process.getOutputStream());
|
||||||
|
out = new DataInputStream(process.getInputStream());
|
||||||
|
testRootShell(in, out);
|
||||||
|
} catch (IOException e1) {
|
||||||
|
rootStatus = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
if (!rootAccess()) {
|
||||||
if (rootAccess()) {
|
// Try to gain non-root sh
|
||||||
try {
|
try {
|
||||||
in.write(("id\n").getBytes("UTF-8"));
|
process = Runtime.getRuntime().exec("sh");
|
||||||
in.flush();
|
in = new DataOutputStream(process.getOutputStream());
|
||||||
String s = new BufferedReader(new InputStreamReader(out)).readLine();
|
out = new DataInputStream(process.getInputStream());
|
||||||
if (TextUtils.isEmpty(s) || !s.contains("uid=0")) {
|
} catch (IOException e) {
|
||||||
in.close();
|
// Nothing works....
|
||||||
out.close();
|
shellProcess = null;
|
||||||
process.destroy();
|
STDIN = null;
|
||||||
throw new IOException();
|
STDOUT = null;
|
||||||
}
|
isValid = false;
|
||||||
} catch (IOException e) {
|
return;
|
||||||
rootStatus = -1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
// Try to gain non-root sh
|
|
||||||
try {
|
|
||||||
process = Runtime.getRuntime().exec("sh");
|
|
||||||
in = new DataOutputStream(process.getOutputStream());
|
|
||||||
out = new DataInputStream(process.getInputStream());
|
|
||||||
} catch (IOException e) {
|
|
||||||
// Nothing works....
|
|
||||||
shellProcess = null;
|
|
||||||
STDIN = null;
|
|
||||||
STDOUT = null;
|
|
||||||
isValid = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user