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
086059ec
Commit
086059ec
authored
Dec 15, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure boot stages are mutually exclusive
parent
7ff22c68
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
28 deletions
+26
-28
bootstages.cpp
native/jni/core/bootstages.cpp
+19
-11
daemon.cpp
native/jni/core/daemon.cpp
+2
-13
daemon.hpp
native/jni/include/daemon.hpp
+4
-3
hide_utils.cpp
native/jni/magiskhide/hide_utils.cpp
+1
-1
No files found.
native/jni/core/bootstages.cpp
View file @
086059ec
...
...
@@ -15,7 +15,6 @@
using
namespace
std
;
static
bool
pfs_done
=
false
;
static
bool
safe_mode
=
false
;
/*********
...
...
@@ -269,21 +268,26 @@ static bool check_key_combo() {
return
true
;
}
/****************
* Entry points *
****************/
/***********************
* Boot Stage Handlers *
***********************/
static
pthread_mutex_t
stage_lock
=
PTHREAD_MUTEX_INITIALIZER
;
void
post_fs_data
(
int
client
)
{
// ack
write_int
(
client
,
0
);
close
(
client
);
mutex_guard
lock
(
stage_lock
);
if
(
getenv
(
"REMOUNT_ROOT"
))
xmount
(
nullptr
,
"/"
,
nullptr
,
MS_REMOUNT
|
MS_RDONLY
,
nullptr
);
if
(
!
check_data
())
goto
unblock_init
;
DAEMON_STATE
=
STATE_POST_FS_DATA
;
setup_logfile
(
true
);
LOGI
(
"** post-fs-data mode running
\n
"
);
...
...
@@ -320,25 +324,27 @@ void post_fs_data(int client) {
handle_modules
();
}
pfs_done
=
true
;
early_abort:
// We still do magic mount because root itself might need it
magic_mount
();
DAEMON_STATE
=
STATE_POST_FS_DATA_DONE
;
unblock_init:
close
(
xopen
(
UNBLOCKFILE
,
O_RDONLY
|
O_CREAT
,
0
));
}
void
late_start
(
int
client
)
{
LOGI
(
"** late_start service mode running
\n
"
);
// ack
write_int
(
client
,
0
);
close
(
client
);
mutex_guard
lock
(
stage_lock
);
run_finally
fin
([]{
DAEMON_STATE
=
STATE_LATE_START_DONE
;
});
setup_logfile
(
false
);
if
(
!
pfs_done
||
safe_mode
)
LOGI
(
"** late_start service mode running
\n
"
);
if
(
DAEMON_STATE
<
STATE_POST_FS_DATA_DONE
||
safe_mode
)
return
;
exec_common_scripts
(
"service"
);
...
...
@@ -346,13 +352,16 @@ void late_start(int client) {
}
void
boot_complete
(
int
client
)
{
LOGI
(
"** boot_complete triggered
\n
"
);
// ack
write_int
(
client
,
0
);
close
(
client
);
mutex_guard
lock
(
stage_lock
);
DAEMON_STATE
=
STATE_BOOT_COMPLETE
;
setup_logfile
(
false
);
LOGI
(
"** boot_complete triggered
\n
"
);
if
(
safe_mode
)
return
;
...
...
@@ -360,7 +369,6 @@ void boot_complete(int client) {
if
(
access
(
SECURE_DIR
,
F_OK
)
!=
0
)
xmkdir
(
SECURE_DIR
,
0700
);
if
(
pfs_done
)
auto_start_magiskhide
();
if
(
!
check_manager
())
{
...
...
native/jni/core/daemon.cpp
View file @
086059ec
...
...
@@ -21,7 +21,7 @@ using namespace std;
int
SDK_INT
=
-
1
;
bool
RECOVERY_MODE
=
false
;
string
MAGISKTMP
;
int
DAEMON_STATE
=
STATE_
UNKNOWN
;
int
DAEMON_STATE
=
STATE_
NONE
;
static
struct
stat
self_st
;
...
...
@@ -99,19 +99,8 @@ static void handle_request(int client) {
break
;
}
switch
(
req_code
)
{
// In case of init trigger launches, set the corresponding states
case
POST_FS_DATA
:
DAEMON_STATE
=
STATE_POST_FS_DATA
;
break
;
case
LATE_START
:
DAEMON_STATE
=
STATE_LATE_START
;
break
;
case
BOOT_COMPLETE
:
DAEMON_STATE
=
STATE_BOOT_COMPLETE
;
break
;
// Simple requests
switch
(
req_code
)
{
case
CHECK_VERSION
:
write_string
(
client
,
MAGISK_VERSION
":MAGISK"
);
goto
shortcut
;
...
...
native/jni/include/daemon.hpp
View file @
086059ec
...
...
@@ -32,10 +32,11 @@ enum {
// Daemon state
enum
{
STATE_NONE
,
STATE_POST_FS_DATA
,
STATE_
LATE_START
,
STATE_
BOOT_COMPLET
E
,
STATE_
UNKNOWN
STATE_
POST_FS_DATA_DONE
,
STATE_
LATE_START_DON
E
,
STATE_
BOOT_COMPLETE
};
extern
int
SDK_INT
;
...
...
native/jni/magiskhide/hide_utils.cpp
View file @
086059ec
...
...
@@ -247,7 +247,7 @@ int launch_magiskhide() {
return
DAEMON_ERROR
;
hide_sensitive_props
();
if
(
DAEMON_STATE
>=
STATE_BOOT_COMPLETE
)
if
(
DAEMON_STATE
>=
STATE_BOOT_COMPLETE
||
DAEMON_STATE
==
STATE_NONE
)
hide_late_sensitive_props
();
// Start monitoring
...
...
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