Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
3cc458ab
Commit
3cc458ab
authored
Aug 12, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always use global mount namespace
parent
337b4c42
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
34 deletions
+36
-34
Shell.java
app/src/main/java/com/topjohnwu/magisk/utils/Shell.java
+36
-34
No files found.
app/src/main/java/com/topjohnwu/magisk/utils/Shell.java
View file @
3cc458ab
...
...
@@ -29,6 +29,17 @@ public class Shell {
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
()
{
rootStatus
=
1
;
Process
process
=
null
;
...
...
@@ -36,45 +47,36 @@ public class Shell {
DataInputStream
out
=
null
;
try
{
process
=
Runtime
.
getRuntime
().
exec
(
"su"
);
// Try getting global namespace
process
=
Runtime
.
getRuntime
().
exec
(
"su --mount-master"
);
in
=
new
DataOutputStream
(
process
.
getOutputStream
());
out
=
new
DataInputStream
(
process
.
getInputStream
());
testRootShell
(
in
,
out
);
}
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
())
{
try
{
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
();
process
.
destroy
();
throw
new
IOException
();
}
}
catch
(
IOException
e
)
{
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
;
if
(!
rootAccess
())
{
// 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
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment