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
0327fd97
Commit
0327fd97
authored
Oct 10, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restart MagiskHide if daemon restarted
parent
e645c6e4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
27 deletions
+43
-27
bootstages.c
jni/daemon/bootstages.c
+2
-13
daemon.c
jni/daemon/daemon.c
+25
-2
log_monitor.c
jni/daemon/log_monitor.c
+11
-12
daemon.h
jni/include/daemon.h
+2
-0
logging.h
jni/include/logging.h
+1
-0
magiskhide.c
jni/magiskhide/magiskhide.c
+2
-0
No files found.
jni/daemon/bootstages.c
View file @
0327fd97
...
...
@@ -551,11 +551,6 @@ static int prepare_img() {
* Entry points *
****************/
static
void
*
start_magisk_hide
(
void
*
args
)
{
launch_magiskhide
(
-
1
);
return
NULL
;
}
static
void
unblock_boot_process
()
{
close
(
open
(
UNBLOCKFILE
,
O_RDONLY
|
O_CREAT
));
pthread_exit
(
NULL
);
...
...
@@ -728,14 +723,8 @@ core_only:
bind_mount
(
HOSTSFILE
,
"/system/etc/hosts"
);
}
// Enable magiskhide by default, only disable when set explicitly
char
*
hide_prop
=
getprop
(
MAGISKHIDE_PROP
);
if
(
hide_prop
==
NULL
||
strcmp
(
hide_prop
,
"0"
)
!=
0
)
{
pthread_t
thread
;
xpthread_create
(
&
thread
,
NULL
,
start_magisk_hide
,
NULL
);
pthread_detach
(
thread
);
}
free
(
hide_prop
);
auto_start_magiskhide
();
unblock:
unblock_boot_process
();
...
...
jni/daemon/daemon.c
View file @
0327fd97
...
...
@@ -21,8 +21,10 @@
#include "utils.h"
#include "daemon.h"
#include "magiskpolicy.h"
#include "resetprop.h"
pthread_t
sepol_patch
;
int
is_restart
=
0
;
static
void
*
request_handler
(
void
*
args
)
{
// Setup the default error handler for threads
...
...
@@ -114,6 +116,21 @@ static void *large_sepol_patch(void *args) {
return
NULL
;
}
static
void
*
start_magisk_hide
(
void
*
args
)
{
launch_magiskhide
(
-
1
);
return
NULL
;
}
void
auto_start_magiskhide
()
{
char
*
hide_prop
=
getprop2
(
MAGISKHIDE_PROP
,
1
);
if
(
hide_prop
==
NULL
||
strcmp
(
hide_prop
,
"0"
)
!=
0
)
{
pthread_t
thread
;
xpthread_create
(
&
thread
,
NULL
,
start_magisk_hide
,
NULL
);
pthread_detach
(
thread
);
}
free
(
hide_prop
);
}
void
start_daemon
()
{
setcon
(
"u:r:su:s0"
);
umask
(
0
);
...
...
@@ -123,9 +140,17 @@ void start_daemon() {
xdup2
(
fd
,
STDERR_FILENO
);
close
(
fd
);
if
((
is_restart
=
check_data
()))
{
// Restart many stuffs
auto_start_magiskhide
();
start_debug_log
();
}
// Start the log monitor
monitor_logs
();
LOGI
(
"Magisk v"
xstr
(
MAGISK_VERSION
)
"("
xstr
(
MAGISK_VER_CODE
)
") daemon started
\n
"
);
// Patch selinux with medium patch before we do anything
load_policydb
(
SELINUX_POLICY
);
sepol_med_rules
();
...
...
@@ -146,8 +171,6 @@ void start_daemon() {
// It should stay intact under any circumstances
err_handler
=
do_nothing
;
LOGI
(
"Magisk v"
xstr
(
MAGISK_VERSION
)
"("
xstr
(
MAGISK_VER_CODE
)
") daemon started
\n
"
);
// Unlock all blocks for rw
unlock_blocks
();
...
...
jni/daemon/log_monitor.c
View file @
0327fd97
...
...
@@ -15,8 +15,7 @@
#include "utils.h"
int
logcat_events
[]
=
{
-
1
,
-
1
,
-
1
};
static
int
is_restart
=
0
;
extern
int
is_restart
;
#ifdef MAGISK_DEBUG
static
int
debug_log_pid
,
debug_log_fd
;
...
...
@@ -120,20 +119,10 @@ static void *debug_magisk_log_thread(void *args) {
void
monitor_logs
()
{
pthread_t
thread
;
is_restart
=
check_data
();
// Start log file dumper before monitor
xpthread_create
(
&
thread
,
NULL
,
magisk_log_thread
,
NULL
);
pthread_detach
(
thread
);
#ifdef MAGISK_DEBUG
if
(
is_restart
)
{
// Restart debug logs
xpthread_create
(
&
thread
,
NULL
,
debug_magisk_log_thread
,
NULL
);
pthread_detach
(
thread
);
}
#endif
// Start logcat monitor
xpthread_create
(
&
thread
,
NULL
,
logger_thread
,
NULL
);
pthread_detach
(
thread
);
...
...
@@ -158,5 +147,15 @@ void stop_debug_full_log() {
// Start debug thread
xpthread_create
(
&
thread
,
NULL
,
debug_magisk_log_thread
,
NULL
);
pthread_detach
(
thread
);
start_debug_log
();
#endif
}
void
start_debug_log
()
{
#ifdef MAGISK_DEBUG
pthread_t
thread
;
// Start debug thread
xpthread_create
(
&
thread
,
NULL
,
debug_magisk_log_thread
,
NULL
);
pthread_detach
(
thread
);
#endif
}
jni/include/daemon.h
View file @
0327fd97
...
...
@@ -7,6 +7,7 @@
#include <pthread.h>
extern
pthread_t
sepol_patch
;
extern
int
is_restart
;
// Commands require connecting to daemon
typedef
enum
{
...
...
@@ -40,6 +41,7 @@ typedef enum {
void
start_daemon
();
int
connect_daemon
();
void
auto_start_magiskhide
();
// socket_trans.c
...
...
jni/include/logging.h
View file @
0327fd97
...
...
@@ -44,6 +44,7 @@ extern int logcat_events[];
void
monitor_logs
();
void
start_debug_full_log
();
void
stop_debug_full_log
();
void
start_debug_log
();
#else // IS_DAEMON
...
...
jni/magiskhide/magiskhide.c
View file @
0327fd97
...
...
@@ -124,6 +124,8 @@ int magiskhide_main(int argc, char *argv[]) {
req
=
RM_HIDELIST
;
}
else
if
(
strcmp
(
argv
[
1
],
"--ls"
)
==
0
)
{
req
=
LS_HIDELIST
;
}
else
{
usage
(
argv
[
0
]);
}
int
fd
=
connect_daemon
();
write_int
(
fd
,
req
);
...
...
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