Reputation: 182
I have a root app that should change some files in another app. My phone is rooted (Samsung Galaxy S21+ 5G) and I use the following code to execute a ls
as test, but I only get the own app directory as long as I have set Mount Namespace Mode to "inherit the requester's namespace". I only see all directories with Global Namespace. The thing I'm not understanding is why I can see all apps using Termux app (su; ls /data/user/0/) even with inherit namespace.
Is there a way to make it work with default namespace setting in Magisk (inherit namespace)?
Process p = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(p.getOutputStream());
os.writeBytes("ls /data/user/0/\n");
os.writeBytes("exit\n");
os.flush();
os.close();
p.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
while (true) {
int read = reader.read(buffer);
int read2 = read;
if (read <= 0) {
System.out.println(output.toString());
}
output.append(buffer, 0, read2);
}
Upvotes: 2
Views: 1299
Reputation: 314
If you are using magisk su, there is a parameter:
--mount-master force run in the global mount namespace
So you change change the command to su --mount-master
Upvotes: 2