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
5be035fd
Commit
5be035fd
authored
Aug 02, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try logging a little harder
parent
f1edc844
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
31 deletions
+38
-31
bootstages.c
native/jni/core/bootstages.c
+19
-0
daemon.c
native/jni/core/daemon.c
+1
-23
log_daemon.c
native/jni/core/log_daemon.c
+15
-1
daemon.h
native/jni/include/daemon.h
+1
-2
magiskrc.h
native/jni/include/magiskrc.h
+1
-4
magiskhide.c
native/jni/magiskhide/magiskhide.c
+1
-1
No files found.
native/jni/core/bootstages.c
View file @
5be035fd
...
@@ -468,6 +468,23 @@ void install_apk(const char *apk) {
...
@@ -468,6 +468,23 @@ void install_apk(const char *apk) {
unlink
(
apk
);
unlink
(
apk
);
}
}
static
void
*
start_magisk_hide
(
void
*
args
)
{
launch_magiskhide
(
-
1
);
return
NULL
;
}
static
void
auto_start_magiskhide
()
{
if
(
!
check_and_start_logger
())
return
;
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
);
}
/****************
/****************
* Entry points *
* Entry points *
****************/
****************/
...
@@ -804,6 +821,8 @@ void late_start(int client) {
...
@@ -804,6 +821,8 @@ void late_start(int client) {
if
(
buf
==
NULL
)
buf
=
xmalloc
(
PATH_MAX
);
if
(
buf
==
NULL
)
buf
=
xmalloc
(
PATH_MAX
);
if
(
buf2
==
NULL
)
buf2
=
xmalloc
(
PATH_MAX
);
if
(
buf2
==
NULL
)
buf2
=
xmalloc
(
PATH_MAX
);
auto_start_magiskhide
();
if
(
full_patch_pid
>
0
)
{
if
(
full_patch_pid
>
0
)
{
// Wait till the full patch is done
// Wait till the full patch is done
waitpid
(
full_patch_pid
,
NULL
,
0
);
waitpid
(
full_patch_pid
,
NULL
,
0
);
...
...
native/jni/core/daemon.c
View file @
5be035fd
...
@@ -93,22 +93,6 @@ static void *request_handler(void *args) {
...
@@ -93,22 +93,6 @@ static void *request_handler(void *args) {
return
NULL
;
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
main_daemon
()
{
void
main_daemon
()
{
setsid
();
setsid
();
setcon
(
"u:r:"
SEPOL_PROC_DOMAIN
":s0"
);
setcon
(
"u:r:"
SEPOL_PROC_DOMAIN
":s0"
);
...
@@ -121,13 +105,7 @@ void main_daemon() {
...
@@ -121,13 +105,7 @@ void main_daemon() {
close
(
fd
);
close
(
fd
);
// Start the log monitor
// Start the log monitor
loggable
=
exec_command_sync
(
"/system/bin/logcat"
,
"-d"
,
"-f"
,
"/dev/null"
,
NULL
)
==
0
;
check_and_start_logger
();
chmod
(
"/dev/null"
,
0666
);
if
(
loggable
)
{
connect_daemon2
(
LOG_DAEMON
,
&
fd
);
write_int
(
fd
,
HANDSHAKE
);
close
(
fd
);
}
struct
sockaddr_un
sun
;
struct
sockaddr_un
sun
;
fd
=
setup_socket
(
&
sun
,
MAIN_DAEMON
);
fd
=
setup_socket
(
&
sun
,
MAIN_DAEMON
);
...
...
native/jni/core/log_daemon.c
View file @
5be035fd
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#include "utils.h"
#include "utils.h"
#include "daemon.h"
#include "daemon.h"
int
loggable
=
1
;
static
int
loggable
=
0
;
static
struct
vector
log_cmd
,
clear_cmd
;
static
struct
vector
log_cmd
,
clear_cmd
;
static
int
sockfd
;
static
int
sockfd
;
static
pthread_mutex_t
lock
=
PTHREAD_MUTEX_INITIALIZER
;
static
pthread_mutex_t
lock
=
PTHREAD_MUTEX_INITIALIZER
;
...
@@ -106,6 +106,20 @@ static void *logcat_thread(void *args) {
...
@@ -106,6 +106,20 @@ static void *logcat_thread(void *args) {
}
}
}
}
int
check_and_start_logger
()
{
if
(
!
loggable
)
{
int
fd
;
loggable
=
exec_command_sync
(
"/system/bin/logcat"
,
"-d"
,
"-f"
,
"/dev/null"
,
NULL
)
==
0
;
chmod
(
"/dev/null"
,
0666
);
if
(
loggable
)
{
connect_daemon2
(
LOG_DAEMON
,
&
fd
);
write_int
(
fd
,
HANDSHAKE
);
close
(
fd
);
}
}
return
loggable
;
}
void
log_daemon
()
{
void
log_daemon
()
{
setsid
();
setsid
();
struct
sockaddr_un
sun
;
struct
sockaddr_un
sun
;
...
...
native/jni/include/daemon.h
View file @
5be035fd
...
@@ -51,12 +51,11 @@ typedef enum {
...
@@ -51,12 +51,11 @@ typedef enum {
void
main_daemon
();
void
main_daemon
();
int
connect_daemon
();
int
connect_daemon
();
int
connect_daemon2
(
daemon_t
d
,
int
*
sockfd
);
int
connect_daemon2
(
daemon_t
d
,
int
*
sockfd
);
void
auto_start_magiskhide
();
// log_monitor.c
// log_monitor.c
extern
int
loggable
;
void
log_daemon
();
void
log_daemon
();
int
check_and_start_logger
();
// socket.c
// socket.c
...
...
native/jni/include/magiskrc.h
View file @
5be035fd
...
@@ -5,11 +5,8 @@ const char magiskrc[] =
...
@@ -5,11 +5,8 @@ const char magiskrc[] =
// Triggers
// Triggers
"on post-fs
\n
"
" start logd
\n
"
"
\n
"
"on post-fs-data
\n
"
"on post-fs-data
\n
"
" start logd
\n
"
" load_persist_props
\n
"
" load_persist_props
\n
"
" rm "
UNBLOCKFILE
"
\n
"
" rm "
UNBLOCKFILE
"
\n
"
" start magisk_startup
\n
"
" start magisk_startup
\n
"
...
...
native/jni/magiskhide/magiskhide.c
View file @
5be035fd
...
@@ -45,7 +45,7 @@ void launch_magiskhide(int client) {
...
@@ -45,7 +45,7 @@ void launch_magiskhide(int client) {
return
;
return
;
}
}
if
(
!
loggable
)
{
if
(
!
check_and_start_logger
()
)
{
if
(
client
>
0
)
{
if
(
client
>
0
)
{
write_int
(
client
,
LOGCAT_DISABLED
);
write_int
(
client
,
LOGCAT_DISABLED
);
close
(
client
);
close
(
client
);
...
...
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