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
8dfb30fe
Commit
8dfb30fe
authored
May 24, 2022
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip cert check on debug builds
parent
2a252d13
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
6 deletions
+4
-6
package.cpp
native/jni/core/package.cpp
+4
-6
No files found.
native/jni/core/package.cpp
View file @
8dfb30fe
...
@@ -103,6 +103,7 @@ int get_manager(int user_id, string *pkg, bool install) {
...
@@ -103,6 +103,7 @@ int get_manager(int user_id, string *pkg, bool install) {
default_new
(
mgr_cert
);
default_new
(
mgr_cert
);
auto
check_dyn
=
[
&
](
int
u
)
->
bool
{
auto
check_dyn
=
[
&
](
int
u
)
->
bool
{
#if ENFORCE_SIGNATURE
snprintf
(
app_path
,
sizeof
(
app_path
),
snprintf
(
app_path
,
sizeof
(
app_path
),
"%s/%d/%s/dyn/current.apk"
,
APP_DATA_DIR
,
u
,
mgr_pkg
->
data
());
"%s/%d/%s/dyn/current.apk"
,
APP_DATA_DIR
,
u
,
mgr_pkg
->
data
());
int
dyn
=
open
(
app_path
,
O_RDONLY
|
O_CLOEXEC
);
int
dyn
=
open
(
app_path
,
O_RDONLY
|
O_CLOEXEC
);
...
@@ -112,11 +113,10 @@ int get_manager(int user_id, string *pkg, bool install) {
...
@@ -112,11 +113,10 @@ int get_manager(int user_id, string *pkg, bool install) {
close
(
dyn
);
close
(
dyn
);
if
(
mismatch
)
{
if
(
mismatch
)
{
LOGE
(
"pkg: dyn APK signature mismatch: %s
\n
"
,
app_path
);
LOGE
(
"pkg: dyn APK signature mismatch: %s
\n
"
,
app_path
);
#if ENFORCE_SIGNATURE
clear_pkg
(
mgr_pkg
->
data
(),
u
);
clear_pkg
(
mgr_pkg
->
data
(),
u
);
return
false
;
return
false
;
#endif
}
}
#endif
return
true
;
return
true
;
};
};
...
@@ -227,22 +227,20 @@ int get_manager(int user_id, string *pkg, bool install) {
...
@@ -227,22 +227,20 @@ int get_manager(int user_id, string *pkg, bool install) {
auto
check_pkg
=
[
&
](
int
u
)
->
bool
{
auto
check_pkg
=
[
&
](
int
u
)
->
bool
{
snprintf
(
app_path
,
sizeof
(
app_path
),
"%s/%d/"
JAVA_PACKAGE_NAME
,
APP_DATA_DIR
,
u
);
snprintf
(
app_path
,
sizeof
(
app_path
),
"%s/%d/"
JAVA_PACKAGE_NAME
,
APP_DATA_DIR
,
u
);
if
(
stat
(
app_path
,
&
st
)
==
0
)
{
if
(
stat
(
app_path
,
&
st
)
==
0
)
{
#if ENFORCE_SIGNATURE
string
apk
=
find_apk_path
(
JAVA_PACKAGE_NAME
);
string
apk
=
find_apk_path
(
JAVA_PACKAGE_NAME
);
int
fd
=
xopen
(
apk
.
data
(),
O_RDONLY
|
O_CLOEXEC
);
int
fd
=
xopen
(
apk
.
data
(),
O_RDONLY
|
O_CLOEXEC
);
string
cert
=
read_certificate
(
fd
);
string
cert
=
read_certificate
(
fd
);
close
(
fd
);
close
(
fd
);
if
(
default_cert
&&
cert
!=
*
default_cert
)
{
if
(
default_cert
&&
cert
!=
*
default_cert
)
{
// Found APK with invalid signature, force replace with stub
// Found APK with invalid signature, force replace with stub
LOGE
(
"pkg: APK signature mismatch: %s
\n
"
,
apk
.
data
());
LOGE
(
"pkg: APK signature mismatch: %s
\n
"
,
apk
.
data
());
#if ENFORCE_SIGNATURE
uninstall_pkg
(
JAVA_PACKAGE_NAME
);
uninstall_pkg
(
JAVA_PACKAGE_NAME
);
invalid
=
true
;
invalid
=
true
;
install
=
true
;
install
=
true
;
return
false
;
return
false
;
#endif
}
}
#endif
mgr_pkg
->
clear
();
mgr_pkg
->
clear
();
mgr_cert
->
clear
();
mgr_cert
->
clear
();
mgr_app_id
=
to_app_id
(
st
.
st_uid
);
mgr_app_id
=
to_app_id
(
st
.
st_uid
);
...
...
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