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
cddeaffa
Commit
cddeaffa
authored
Oct 13, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove err_handler
parent
2a8898e7
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
3 additions
and
62 deletions
+3
-62
bootstages.c
jni/daemon/bootstages.c
+0
-6
daemon.c
jni/daemon/daemon.c
+0
-6
log_monitor.c
jni/daemon/log_monitor.c
+0
-9
magisk.c
jni/daemon/magisk.c
+0
-6
logging.h
jni/include/logging.h
+1
-9
hide_utils.c
jni/magiskhide/hide_utils.c
+0
-3
magiskhide.c
jni/magiskhide/magiskhide.c
+0
-3
proc_monitor.c
jni/magiskhide/proc_monitor.c
+1
-16
su
jni/su
+1
-1
misc.c
jni/utils/misc.c
+0
-3
No files found.
jni/daemon/bootstages.c
View file @
cddeaffa
...
@@ -574,9 +574,6 @@ static void unblock_boot_process() {
...
@@ -574,9 +574,6 @@ static void unblock_boot_process() {
}
}
void
post_fs
(
int
client
)
{
void
post_fs
(
int
client
)
{
// Error handler
err_handler
=
unblock_boot_process
;
LOGI
(
"** post-fs mode running
\n
"
);
LOGI
(
"** post-fs mode running
\n
"
);
// ack
// ack
write_int
(
client
,
0
);
write_int
(
client
,
0
);
...
@@ -598,9 +595,6 @@ unblock:
...
@@ -598,9 +595,6 @@ unblock:
}
}
void
post_fs_data
(
int
client
)
{
void
post_fs_data
(
int
client
)
{
// Error handler
err_handler
=
unblock_boot_process
;
// ack
// ack
write_int
(
client
,
0
);
write_int
(
client
,
0
);
close
(
client
);
close
(
client
);
...
...
jni/daemon/daemon.c
View file @
cddeaffa
...
@@ -27,9 +27,6 @@ pthread_t sepol_patch;
...
@@ -27,9 +27,6 @@ pthread_t sepol_patch;
int
is_restart
=
0
;
int
is_restart
=
0
;
static
void
*
request_handler
(
void
*
args
)
{
static
void
*
request_handler
(
void
*
args
)
{
// Setup the default error handler for threads
err_handler
=
exit_thread
;
int
client
=
*
((
int
*
)
args
);
int
client
=
*
((
int
*
)
args
);
free
(
args
);
free
(
args
);
client_request
req
=
read_int
(
client
);
client_request
req
=
read_int
(
client
);
...
@@ -168,9 +165,6 @@ void start_daemon() {
...
@@ -168,9 +165,6 @@ void start_daemon() {
// Change process name
// Change process name
strcpy
(
argv0
,
"magisk_daemon"
);
strcpy
(
argv0
,
"magisk_daemon"
);
// The root daemon should not do anything if an error occurs
// It should stay intact under any circumstances
err_handler
=
do_nothing
;
// Unlock all blocks for rw
// Unlock all blocks for rw
unlock_blocks
();
unlock_blocks
();
...
...
jni/daemon/log_monitor.c
View file @
cddeaffa
...
@@ -22,9 +22,6 @@ static int debug_log_pid, debug_log_fd;
...
@@ -22,9 +22,6 @@ static int debug_log_pid, debug_log_fd;
#endif
#endif
static
void
*
logger_thread
(
void
*
args
)
{
static
void
*
logger_thread
(
void
*
args
)
{
// Setup error handler
err_handler
=
exit_thread
;
int
log_fd
=
-
1
,
log_pid
;
int
log_fd
=
-
1
,
log_pid
;
char
line
[
4096
];
char
line
[
4096
];
...
@@ -50,9 +47,6 @@ static void *logger_thread(void *args) {
...
@@ -50,9 +47,6 @@ static void *logger_thread(void *args) {
}
}
static
void
*
magisk_log_thread
(
void
*
args
)
{
static
void
*
magisk_log_thread
(
void
*
args
)
{
// Setup error handler
err_handler
=
exit_thread
;
int
have_data
=
0
;
int
have_data
=
0
;
// Temp buffer for logs before we have data access
// Temp buffer for logs before we have data access
...
@@ -95,9 +89,6 @@ static void *magisk_log_thread(void *args) {
...
@@ -95,9 +89,6 @@ static void *magisk_log_thread(void *args) {
}
}
static
void
*
debug_magisk_log_thread
(
void
*
args
)
{
static
void
*
debug_magisk_log_thread
(
void
*
args
)
{
// Setup error handler
err_handler
=
exit_thread
;
FILE
*
log
=
xfopen
(
DEBUG_LOG
,
"a"
);
FILE
*
log
=
xfopen
(
DEBUG_LOG
,
"a"
);
setbuf
(
log
,
NULL
);
setbuf
(
log
,
NULL
);
int
pipefd
[
2
];
int
pipefd
[
2
];
...
...
jni/daemon/magisk.c
View file @
cddeaffa
...
@@ -32,10 +32,6 @@ int create_links(const char *bin, const char *path) {
...
@@ -32,10 +32,6 @@ int create_links(const char *bin, const char *path) {
return
ret
;
return
ret
;
}
}
// Global error hander function
// Should be changed each thread/process
__thread
void
(
*
err_handler
)(
void
);
static
void
usage
()
{
static
void
usage
()
{
fprintf
(
stderr
,
fprintf
(
stderr
,
"Magisk v"
xstr
(
MAGISK_VERSION
)
"("
xstr
(
MAGISK_VER_CODE
)
") (by topjohnwu) multi-call binary
\n
"
"Magisk v"
xstr
(
MAGISK_VERSION
)
"("
xstr
(
MAGISK_VER_CODE
)
") (by topjohnwu) multi-call binary
\n
"
...
@@ -72,8 +68,6 @@ static void usage() {
...
@@ -72,8 +68,6 @@ static void usage() {
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
argv0
=
argv
[
0
];
argv0
=
argv
[
0
];
// Exit the whole app if error occurs by default
err_handler
=
exit_proc
;
char
*
arg
=
strrchr
(
argv
[
0
],
'/'
);
char
*
arg
=
strrchr
(
argv
[
0
],
'/'
);
if
(
arg
)
++
arg
;
if
(
arg
)
++
arg
;
else
arg
=
argv
[
0
];
else
arg
=
argv
[
0
];
...
...
jni/include/logging.h
View file @
cddeaffa
...
@@ -15,14 +15,6 @@
...
@@ -15,14 +15,6 @@
#define LOG_TAG "Magisk"
#define LOG_TAG "Magisk"
// Global handler for PLOGE
extern
__thread
void
(
*
err_handler
)(
void
);
// Common error handlers
static
inline
void
exit_proc
()
{
exit
(
1
);
}
static
inline
void
exit_thread
()
{
pthread_exit
(
NULL
);
}
static
inline
void
do_nothing
()
{}
#ifdef MAGISK_DEBUG
#ifdef MAGISK_DEBUG
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#else
#else
...
@@ -32,7 +24,7 @@ static inline void do_nothing() {}
...
@@ -32,7 +24,7 @@ static inline void do_nothing() {}
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
#define PLOGE(fmt, args...)
{ LOGE(fmt " failed with %d: %s", ##args, errno, strerror(errno)); err_handler(); }
#define PLOGE(fmt, args...)
LOGE(fmt " failed with %d: %s", ##args, errno, strerror(errno))
enum
{
enum
{
HIDE_EVENT
,
HIDE_EVENT
,
...
...
jni/magiskhide/hide_utils.c
View file @
cddeaffa
...
@@ -187,7 +187,6 @@ int destroy_list() {
...
@@ -187,7 +187,6 @@ int destroy_list() {
}
}
void
add_hide_list
(
int
client
)
{
void
add_hide_list
(
int
client
)
{
err_handler
=
do_nothing
;
char
*
proc
=
read_string
(
client
);
char
*
proc
=
read_string
(
client
);
// ack
// ack
write_int
(
client
,
add_list
(
proc
));
write_int
(
client
,
add_list
(
proc
));
...
@@ -195,7 +194,6 @@ void add_hide_list(int client) {
...
@@ -195,7 +194,6 @@ void add_hide_list(int client) {
}
}
void
rm_hide_list
(
int
client
)
{
void
rm_hide_list
(
int
client
)
{
err_handler
=
do_nothing
;
char
*
proc
=
read_string
(
client
);
char
*
proc
=
read_string
(
client
);
// ack
// ack
write_int
(
client
,
rm_list
(
proc
));
write_int
(
client
,
rm_list
(
proc
));
...
@@ -203,7 +201,6 @@ void rm_hide_list(int client) {
...
@@ -203,7 +201,6 @@ void rm_hide_list(int client) {
}
}
void
ls_hide_list
(
int
client
)
{
void
ls_hide_list
(
int
client
)
{
err_handler
=
do_nothing
;
if
(
!
hideEnabled
)
{
if
(
!
hideEnabled
)
{
write_int
(
client
,
HIDE_NOT_ENABLED
);
write_int
(
client
,
HIDE_NOT_ENABLED
);
return
;
return
;
...
...
jni/magiskhide/magiskhide.c
View file @
cddeaffa
...
@@ -41,9 +41,6 @@ static void usage(char *arg0) {
...
@@ -41,9 +41,6 @@ static void usage(char *arg0) {
}
}
void
launch_magiskhide
(
int
client
)
{
void
launch_magiskhide
(
int
client
)
{
// We manually handle crashes
err_handler
=
do_nothing
;
if
(
hideEnabled
)
{
if
(
hideEnabled
)
{
if
(
client
>
0
)
{
if
(
client
>
0
)
{
write_int
(
client
,
HIDE_IS_ENABLED
);
write_int
(
client
,
HIDE_IS_ENABLED
);
...
...
jni/magiskhide/proc_monitor.c
View file @
cddeaffa
...
@@ -24,7 +24,6 @@ static int zygote_num, has_cache = 1, pipefd[2] = { -1, -1 };
...
@@ -24,7 +24,6 @@ static int zygote_num, has_cache = 1, pipefd[2] = { -1, -1 };
// Workaround for the lack of pthread_cancel
// Workaround for the lack of pthread_cancel
static
void
quit_pthread
(
int
sig
)
{
static
void
quit_pthread
(
int
sig
)
{
err_handler
=
do_nothing
;
LOGD
(
"proc_monitor: running cleanup
\n
"
);
LOGD
(
"proc_monitor: running cleanup
\n
"
);
destroy_list
();
destroy_list
();
hideEnabled
=
0
;
hideEnabled
=
0
;
...
@@ -39,11 +38,6 @@ static void quit_pthread(int sig) {
...
@@ -39,11 +38,6 @@ static void quit_pthread(int sig) {
pthread_exit
(
NULL
);
pthread_exit
(
NULL
);
}
}
static
void
proc_monitor_err
()
{
LOGE
(
"proc_monitor: error occured, stopping magiskhide services
\n
"
);
quit_pthread
(
SIGUSR1
);
}
static
int
read_namespace
(
const
int
pid
,
char
*
target
,
const
size_t
size
)
{
static
int
read_namespace
(
const
int
pid
,
char
*
target
,
const
size_t
size
)
{
char
path
[
32
];
char
path
[
32
];
snprintf
(
path
,
sizeof
(
path
),
"/proc/%d/ns/mnt"
,
pid
);
snprintf
(
path
,
sizeof
(
path
),
"/proc/%d/ns/mnt"
,
pid
);
...
@@ -69,14 +63,8 @@ static void lazy_unmount(const char* mountpoint) {
...
@@ -69,14 +63,8 @@ static void lazy_unmount(const char* mountpoint) {
LOGD
(
"hide_daemon: Unmount Failed (%s)
\n
"
,
mountpoint
);
LOGD
(
"hide_daemon: Unmount Failed (%s)
\n
"
,
mountpoint
);
}
}
static
void
hide_daemon_err
()
{
LOGE
(
"hide_daemon: error occured
\n
"
);
}
static
void
hide_daemon
(
int
pid
)
{
static
void
hide_daemon
(
int
pid
)
{
LOGD
(
"hide_daemon: start unmount for pid=[%d]
\n
"
,
pid
);
LOGD
(
"hide_daemon: start unmount for pid=[%d]
\n
"
,
pid
);
// When an error occurs, report its failure
err_handler
=
hide_daemon_err
;
char
*
line
,
buffer
[
PATH_MAX
];
char
*
line
,
buffer
[
PATH_MAX
];
struct
vector
mount_list
;
struct
vector
mount_list
;
...
@@ -152,15 +140,12 @@ void proc_monitor() {
...
@@ -152,15 +140,12 @@ void proc_monitor() {
act
.
sa_handler
=
quit_pthread
;
act
.
sa_handler
=
quit_pthread
;
sigaction
(
SIGUSR1
,
&
act
,
NULL
);
sigaction
(
SIGUSR1
,
&
act
,
NULL
);
// The error handler should stop magiskhide services
err_handler
=
proc_monitor_err
;
cache_block
[
0
]
=
'\0'
;
cache_block
[
0
]
=
'\0'
;
// Get the mount namespace of init
// Get the mount namespace of init
if
(
read_namespace
(
1
,
init_ns
,
32
))
{
if
(
read_namespace
(
1
,
init_ns
,
32
))
{
LOGE
(
"proc_monitor: Your kernel doesn't support mount namespace :(
\n
"
);
LOGE
(
"proc_monitor: Your kernel doesn't support mount namespace :(
\n
"
);
proc_monitor_err
(
);
quit_pthread
(
SIGUSR1
);
}
}
LOGI
(
"proc_monitor: init ns=%s
\n
"
,
init_ns
);
LOGI
(
"proc_monitor: init ns=%s
\n
"
,
init_ns
);
...
...
su
@
6de95e0d
Subproject commit
c912c192e0d03119a14d7b772caa5d77bc4b7999
Subproject commit
6de95e0d9bb6aa3e657a7e1492eed1b632c9f186
jni/utils/misc.c
View file @
cddeaffa
...
@@ -243,9 +243,6 @@ static int v_exec_command(int err, int *fd, void (*setupenv)(struct vector*), co
...
@@ -243,9 +243,6 @@ static int v_exec_command(int err, int *fd, void (*setupenv)(struct vector*), co
return
pid
;
return
pid
;
}
}
// Don't return to the daemon if anything goes wrong
err_handler
=
exit_proc
;
if
(
fd
)
{
if
(
fd
)
{
xdup2
(
writeEnd
,
STDOUT_FILENO
);
xdup2
(
writeEnd
,
STDOUT_FILENO
);
if
(
err
)
xdup2
(
writeEnd
,
STDERR_FILENO
);
if
(
err
)
xdup2
(
writeEnd
,
STDERR_FILENO
);
...
...
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