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
0faed715
Commit
0faed715
authored
Apr 29, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add invincible mode back
parent
fb491cfd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
2 deletions
+29
-2
daemon.c
native/jni/core/daemon.c
+29
-2
No files found.
native/jni/core/daemon.c
View file @
0faed715
...
@@ -94,6 +94,30 @@ static void *start_magisk_hide(void *args) {
...
@@ -94,6 +94,30 @@ static void *start_magisk_hide(void *args) {
return
NULL
;
return
NULL
;
}
}
static
void
daemon_saver
()
{
int
fd
,
val
;
struct
sockaddr_un
sun
;
// Change process name
strcpy
(
argv0
,
"magisk_saver"
);
while
(
1
)
{
fd
=
setup_socket
(
&
sun
);
while
(
connect
(
fd
,
(
struct
sockaddr
*
)
&
sun
,
sizeof
(
sun
)))
usleep
(
10000
);
write_int
(
fd
,
DO_NOTHING
);
// Should hold forever unless the other side is closed
read
(
fd
,
&
val
,
sizeof
(
int
));
// If it came here, the daemon is terminated
close
(
fd
);
if
(
fork_dont_care
()
==
0
)
start_daemon
(
0
);
}
}
void
auto_start_magiskhide
()
{
void
auto_start_magiskhide
()
{
char
*
hide_prop
=
getprop2
(
MAGISKHIDE_PROP
,
1
);
char
*
hide_prop
=
getprop2
(
MAGISKHIDE_PROP
,
1
);
if
(
hide_prop
==
NULL
||
strcmp
(
hide_prop
,
"0"
)
!=
0
)
{
if
(
hide_prop
==
NULL
||
strcmp
(
hide_prop
,
"0"
)
!=
0
)
{
...
@@ -113,6 +137,9 @@ void start_daemon(int post_fs_data) {
...
@@ -113,6 +137,9 @@ void start_daemon(int post_fs_data) {
xdup2
(
fd
,
STDERR_FILENO
);
xdup2
(
fd
,
STDERR_FILENO
);
close
(
fd
);
close
(
fd
);
if
(
post_fs_data
&&
fork_dont_care
()
==
0
)
daemon_saver
();
// Block user signals
// Block user signals
sigset_t
block_set
;
sigset_t
block_set
;
sigemptyset
(
&
block_set
);
sigemptyset
(
&
block_set
);
...
@@ -140,7 +167,7 @@ void start_daemon(int post_fs_data) {
...
@@ -140,7 +167,7 @@ void start_daemon(int post_fs_data) {
LOGI
(
"Magisk v"
xstr
(
MAGISK_VERSION
)
"("
xstr
(
MAGISK_VER_CODE
)
") daemon started
\n
"
);
LOGI
(
"Magisk v"
xstr
(
MAGISK_VERSION
)
"("
xstr
(
MAGISK_VER_CODE
)
") daemon started
\n
"
);
// Change process name
// Change process name
strcpy
(
argv0
,
"magisk
_daemon
"
);
strcpy
(
argv0
,
"magisk
d
"
);
// Loop forever to listen for requests
// Loop forever to listen for requests
while
(
1
)
{
while
(
1
)
{
...
@@ -165,7 +192,7 @@ int connect_daemon(int post_fs_data) {
...
@@ -165,7 +192,7 @@ int connect_daemon(int post_fs_data) {
exit
(
1
);
exit
(
1
);
}
}
if
(
xfork
()
==
0
)
{
if
(
fork_dont_care
()
==
0
)
{
LOGD
(
"client: connect fail, try launching new daemon process
\n
"
);
LOGD
(
"client: connect fail, try launching new daemon process
\n
"
);
close
(
fd
);
close
(
fd
);
start_daemon
(
post_fs_data
);
start_daemon
(
post_fs_data
);
...
...
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