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
4c230d9e
Commit
4c230d9e
authored
Sep 04, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Root shell workaround
parent
727294fb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
11 deletions
+37
-11
InstallMagisk.java
.../main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
+9
-11
Shell.java
app/src/main/java/com/topjohnwu/magisk/utils/Shell.java
+28
-0
No files found.
app/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
View file @
4c230d9e
...
...
@@ -154,8 +154,16 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
mList
.
add
(
"- Use boot image: "
+
boot
);
Shell
shell
;
if
(
mode
==
PATCH_MODE
&&
Shell
.
rootAccess
())
{
// Force non-root shell
shell
=
Shell
.
getShell
(
"sh"
);
}
else
{
shell
=
getShell
();
}
// Patch boot image
getShell
()
.
sh
(
mList
,
shell
.
sh
(
mList
,
"cd "
+
install
,
"KEEPFORCEENCRYPT="
+
mKeepEnc
+
" KEEPVERITY="
+
mKeepVerity
+
" sh "
+
"update-binary indep boot_patch.sh "
+
boot
+
" 2>&1"
+
...
...
@@ -176,16 +184,6 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
getShell
().
sh_raw
(
"cp -f "
+
patched_boot
+
" "
+
dest
);
break
;
case
".img.tar"
:
// Workaround root shell issues so we can access the file through Java
if
(
Shell
.
rootAccess
())
{
// Get non-root UID
int
uid
=
mm
.
getApplicationInfo
().
uid
;
// Get app selabel
String
selabel
=
getShell
().
su
(
"/system/bin/ls -dZ "
+
install
+
" | cut -d' ' -f1"
).
get
(
0
);
getShell
().
su
(
"chcon "
+
selabel
+
" "
+
patched_boot
,
"chown "
+
uid
+
"."
+
uid
+
" "
+
patched_boot
);
}
TarOutputStream
tar
=
new
TarOutputStream
(
new
BufferedOutputStream
(
new
FileOutputStream
(
dest
)));
tar
.
putNextEntry
(
new
TarEntry
(
patched_boot
,
"boot.img"
));
byte
buffer
[]
=
new
byte
[
4096
];
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Shell.java
View file @
4c230d9e
...
...
@@ -87,10 +87,38 @@ public class Shell {
sh_raw
(
"umask 022"
);
}
private
Shell
(
String
command
)
{
Process
process
;
DataOutputStream
in
;
DataInputStream
out
;
try
{
process
=
Runtime
.
getRuntime
().
exec
(
command
);
in
=
new
DataOutputStream
(
process
.
getOutputStream
());
out
=
new
DataInputStream
(
process
.
getInputStream
());
}
catch
(
IOException
e
)
{
// Nothing works....
shellProcess
=
null
;
STDIN
=
null
;
STDOUT
=
null
;
isValid
=
false
;
return
;
}
isValid
=
true
;
shellProcess
=
process
;
STDIN
=
in
;
STDOUT
=
out
;
}
public
static
Shell
getShell
()
{
return
new
Shell
();
}
public
static
Shell
getShell
(
String
command
)
{
return
new
Shell
(
command
);
}
public
static
Shell
getShell
(
Context
context
)
{
MagiskManager
magiskManager
=
Utils
.
getMagiskManager
(
context
);
if
(
magiskManager
.
shell
==
null
||
!
magiskManager
.
shell
.
isValid
)
{
...
...
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