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
6c4d81b1
Commit
6c4d81b1
authored
Jul 02, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Invincible mode implemented in magisklogd
parent
c88dc879
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
9 deletions
+46
-9
bootstages.c
native/jni/core/bootstages.c
+1
-1
daemon.c
native/jni/core/daemon.c
+16
-7
log_monitor.c
native/jni/core/log_monitor.c
+27
-0
daemon.h
native/jni/include/daemon.h
+1
-0
su
native/jni/su
+1
-1
No files found.
native/jni/core/bootstages.c
View file @
6c4d81b1
...
...
@@ -662,7 +662,7 @@ void startup() {
}
// Start post-fs-data mode
execl
(
"/sbin/magisk"
,
"magisk"
,
"--post-fs-data"
,
NULL
);
execl
(
"/sbin/magisk
.bin
"
,
"magisk"
,
"--post-fs-data"
,
NULL
);
}
void
post_fs_data
(
int
client
)
{
...
...
native/jni/core/daemon.c
View file @
6c4d81b1
...
...
@@ -83,6 +83,9 @@ static void *request_handler(void *args) {
case
LATE_START
:
late_start
(
client
);
break
;
case
MONITOR
:
/* Do NOT close the client, make it hold */
break
;
default:
close
(
client
);
break
;
...
...
@@ -117,13 +120,6 @@ void main_daemon() {
xdup2
(
fd
,
STDIN_FILENO
);
close
(
fd
);
// Block user signals
sigset_t
block_set
;
sigemptyset
(
&
block_set
);
sigaddset
(
&
block_set
,
SIGUSR1
);
sigaddset
(
&
block_set
,
SIGUSR2
);
pthread_sigmask
(
SIG_SETMASK
,
&
block_set
,
NULL
);
// Start the log monitor
monitor_logs
();
...
...
@@ -138,6 +134,19 @@ void main_daemon() {
// Change process name
strcpy
(
argv0
,
"magiskd"
);
// Block all user signals
sigset_t
block_set
;
sigemptyset
(
&
block_set
);
sigaddset
(
&
block_set
,
SIGUSR1
);
sigaddset
(
&
block_set
,
SIGUSR2
);
pthread_sigmask
(
SIG_SETMASK
,
&
block_set
,
NULL
);
// Ignore SIGPIPE
struct
sigaction
act
;
memset
(
&
act
,
0
,
sizeof
(
act
));
act
.
sa_handler
=
SIG_IGN
;
sigaction
(
SIGPIPE
,
&
act
,
NULL
);
// Loop forever to listen for requests
while
(
1
)
{
int
*
client
=
xmalloc
(
sizeof
(
int
));
...
...
native/jni/core/log_monitor.c
View file @
6c4d81b1
...
...
@@ -85,6 +85,26 @@ static void *socket_thread(void *args) {
}
}
static
void
*
monitor_thread
(
void
*
args
)
{
// Block SIGPIPE to prevent interruption
sigset_t
block_set
;
sigemptyset
(
&
block_set
);
sigaddset
(
&
block_set
,
SIGPIPE
);
pthread_sigmask
(
SIG_SETMASK
,
&
block_set
,
NULL
);
// Give the main daemon some time before we monitor it
sleep
(
5
);
int
fd
;
char
b
[
1
];
do
{
fd
=
connect_daemon
();
write_int
(
fd
,
MONITOR
);
// This should hold unless the daemon is killed
read
(
fd
,
b
,
sizeof
(
b
));
// The main daemon crashed, spawn a new one
close
(
fd
);
}
while
(
1
);
}
void
log_daemon
()
{
setsid
();
strcpy
(
argv0
,
"magisklogd"
);
...
...
@@ -96,6 +116,13 @@ void log_daemon() {
xlisten
(
sockfd
,
1
);
LOGI
(
"Magisk v"
xstr
(
MAGISK_VERSION
)
"("
xstr
(
MAGISK_VER_CODE
)
") logger started
\n
"
);
// Start invincible mode monitor
// TODO: Remove this when all crashes are fixed
pthread_t
t
;
pthread_create
(
&
t
,
NULL
,
monitor_thread
,
NULL
);
pthread_detach
(
t
);
// Set SIGPIPE handler
struct
sigaction
act
;
memset
(
&
act
,
0
,
sizeof
(
act
));
act
.
sa_handler
=
sigpipe_handler
;
...
...
native/jni/include/daemon.h
View file @
6c4d81b1
...
...
@@ -25,6 +25,7 @@ enum {
ADD_HIDELIST
,
RM_HIDELIST
,
LS_HIDELIST
,
MONITOR
,
HIDE_CONNECT
};
...
...
su
@
69b226b0
Subproject commit
ead8c03a3a6eed6621ffcf4bc2fd12429da3596
e
Subproject commit
69b226b005e3f87c4c872fa3382e05006969118
e
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