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
a1ccd440
Commit
a1ccd440
authored
Sep 21, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change MagiskBoot patch behavior
Use environment variables to toggle configurations for patching ramdisk
parent
4d91e50d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
9 deletions
+23
-9
main.cpp
native/jni/magiskboot/main.cpp
+3
-2
ramdisk.cpp
native/jni/magiskboot/ramdisk.cpp
+17
-6
boot_patch.sh
scripts/boot_patch.sh
+3
-1
No files found.
native/jni/magiskboot/main.cpp
View file @
a1ccd440
...
...
@@ -61,8 +61,9 @@ Supported actions:
Test the current cpio's patch status
Return values:
0:stock 1:Magisk 2:unsupported (phh, SuperSU, Xposed)
patch KEEPVERITY KEEPFORCEENCRYPT
Ramdisk patches. KEEP**** are boolean values
patch
Apply ramdisk patches. Configure settings with env variables:
KEEPVERITY KEEPFORCEENCRYPT
backup ORIG
Create ramdisk backups from ORIG
restore
...
...
native/jni/magiskboot/ramdisk.cpp
View file @
a1ccd440
...
...
@@ -24,7 +24,7 @@ class magisk_cpio : public cpio_rw {
public
:
magisk_cpio
()
=
default
;
explicit
magisk_cpio
(
const
char
*
filename
)
:
cpio_rw
(
filename
)
{}
void
patch
(
bool
keepverity
,
bool
keepforceencrypt
);
void
patch
();
int
test
();
char
*
sha1
();
void
restore
();
...
...
@@ -33,9 +33,17 @@ public:
void
decompress
();
};
void
magisk_cpio
::
patch
(
bool
keepverity
,
bool
keepforceencrypt
)
{
static
bool
check_env
(
const
char
*
name
)
{
const
char
*
val
=
getenv
(
name
);
return
val
?
strcmp
(
val
,
"true"
)
==
0
:
false
;
}
void
magisk_cpio
::
patch
()
{
bool
keepverity
=
check_env
(
"KEEPVERITY"
);
bool
keepforceencrypt
=
check_env
(
"KEEPFORCEENCRYPT"
);
fprintf
(
stderr
,
"Patch with flag KEEPVERITY=[%s] KEEPFORCEENCRYPT=[%s]
\n
"
,
keepverity
?
"true"
:
"false"
,
keepforceencrypt
?
"true"
:
"false"
);
auto
next
=
entries
.
begin
();
decltype
(
next
)
cur
;
while
(
next
!=
entries
.
end
())
{
...
...
@@ -46,9 +54,12 @@ void magisk_cpio::patch(bool keepverity, bool keepforceencrypt) {
str_contains
(
cur
->
first
,
"fstab"
)
&&
S_ISREG
(
cur
->
second
->
mode
);
if
(
!
keepverity
)
{
if
(
fstab
)
{
fprintf
(
stderr
,
"Found fstab file [%s]
\n
"
,
cur
->
first
.
data
());
auto
buf
=
patch_verity
(
cur
->
second
->
data
,
cur
->
second
->
filesize
);
free
(
cur
->
second
->
data
);
cur
->
second
->
data
=
buf
;
if
(
buf
)
{
free
(
cur
->
second
->
data
);
cur
->
second
->
data
=
buf
;
}
}
else
if
(
cur
->
first
==
"verity_key"
)
{
rm
(
cur
);
continue
;
...
...
@@ -293,6 +304,8 @@ int cpio_commands(int argc, char *argv[]) {
cpio
.
compress
();
}
else
if
(
strcmp
(
cmdv
[
0
],
"decompress"
)
==
0
){
cpio
.
decompress
();
}
else
if
(
strcmp
(
cmdv
[
0
],
"patch"
)
==
0
)
{
cpio
.
patch
();
}
else
if
(
cmdc
==
2
&&
strcmp
(
cmdv
[
0
],
"exists"
)
==
0
)
{
exit
(
!
cpio
.
exists
(
cmdv
[
1
]));
}
else
if
(
cmdc
==
2
&&
strcmp
(
cmdv
[
0
],
"backup"
)
==
0
)
{
...
...
@@ -302,8 +315,6 @@ int cpio_commands(int argc, char *argv[]) {
cpio
.
rm
(
cmdv
[
1
+
r
],
r
);
}
else
if
(
cmdc
==
3
&&
strcmp
(
cmdv
[
0
],
"mv"
)
==
0
)
{
cpio
.
mv
(
cmdv
[
1
],
cmdv
[
2
]);
}
else
if
(
cmdc
==
3
&&
strcmp
(
cmdv
[
0
],
"patch"
)
==
0
)
{
cpio
.
patch
(
strcmp
(
cmdv
[
1
],
"true"
)
==
0
,
strcmp
(
cmdv
[
2
],
"true"
)
==
0
);
}
else
if
(
strcmp
(
cmdv
[
0
],
"extract"
)
==
0
)
{
if
(
cmdc
==
3
)
{
return
!
cpio
.
extract
(
cmdv
[
1
],
cmdv
[
2
]);
...
...
scripts/boot_patch.sh
View file @
a1ccd440
...
...
@@ -59,6 +59,8 @@ BOOTIMAGE="$1"
[
-z
$KEEPVERITY
]
&&
KEEPVERITY
=
false
[
-z
$KEEPFORCEENCRYPT
]
&&
KEEPFORCEENCRYPT
=
false
[
-z
$RECOVERYMODE
]
&&
RECOVERYMODE
=
false
export
KEEPVERITY
export
KEEPFORCEENCRYPT
chmod
-R
755
.
...
...
@@ -140,7 +142,7 @@ echo "RECOVERYMODE=$RECOVERYMODE" >> config
./magiskboot cpio ramdisk.cpio
\
"add 750 init magiskinit"
\
"patch
$KEEPVERITY
$KEEPFORCEENCRYPT
"
\
"patch"
\
"backup ramdisk.cpio.orig"
\
"mkdir 000 .backup"
\
"add 000 .backup/.magisk config"
...
...
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