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
6017ff23
Commit
6017ff23
authored
May 01, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Close files, cleanup resourses
parent
e16d604d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
12 deletions
+17
-12
bootstages.c
jni/daemon/bootstages.c
+3
-0
daemon.c
jni/daemon/daemon.c
+5
-3
log_monitor.c
jni/daemon/log_monitor.c
+2
-0
magisk.h
jni/magisk.h
+1
-0
misc.c
jni/utils/misc.c
+6
-9
No files found.
jni/daemon/bootstages.c
View file @
6017ff23
...
@@ -62,6 +62,8 @@ static char *loopsetup(const char *img) {
...
@@ -62,6 +62,8 @@ static char *loopsetup(const char *img) {
return
NULL
;
return
NULL
;
strcpy
((
char
*
)
info
.
lo_file_name
,
img
);
strcpy
((
char
*
)
info
.
lo_file_name
,
img
);
ioctl
(
lfd
,
LOOP_SET_STATUS64
,
&
info
);
ioctl
(
lfd
,
LOOP_SET_STATUS64
,
&
info
);
close
(
lfd
);
close
(
ffd
);
return
strdup
(
device
);
return
strdup
(
device
);
}
}
...
@@ -241,6 +243,7 @@ static void clone_skeleton(struct node_entry *node, const char *real_path) {
...
@@ -241,6 +243,7 @@ static void clone_skeleton(struct node_entry *node, const char *real_path) {
insert_child
(
node
,
dummy
);
insert_child
(
node
,
dummy
);
}
}
}
}
closedir
(
dir
);
snprintf
(
buf
,
PATH_MAX
,
"/dev/magisk/dummy%s"
,
real_path
);
snprintf
(
buf
,
PATH_MAX
,
"/dev/magisk/dummy%s"
,
real_path
);
xmkdir_p
(
buf
,
0755
);
xmkdir_p
(
buf
,
0755
);
...
...
jni/daemon/daemon.c
View file @
6017ff23
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include "magiskpolicy.h"
#include "magiskpolicy.h"
pthread_t
sepol_patch
;
pthread_t
sepol_patch
;
int
null_fd
;
static
void
*
request_handler
(
void
*
args
)
{
static
void
*
request_handler
(
void
*
args
)
{
// Setup the default error handler for threads
// Setup the default error handler for threads
...
@@ -111,9 +112,10 @@ void start_daemon() {
...
@@ -111,9 +112,10 @@ void start_daemon() {
xsetsid
();
xsetsid
();
setcon
(
"u:r:su:s0"
);
setcon
(
"u:r:su:s0"
);
umask
(
022
);
umask
(
022
);
close
(
STDIN_FILENO
);
null_fd
=
xopen
(
"/dev/null"
,
O_RDWR
);
close
(
STDOUT_FILENO
);
xdup2
(
null_fd
,
STDIN_FILENO
);
close
(
STDERR_FILENO
);
xdup2
(
null_fd
,
STDOUT_FILENO
);
xdup2
(
null_fd
,
STDERR_FILENO
);
// Patch selinux with medium patch before we do anything
// Patch selinux with medium patch before we do anything
load_policydb
(
SELINUX_POLICY
);
load_policydb
(
SELINUX_POLICY
);
...
...
jni/daemon/log_monitor.c
View file @
6017ff23
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <stdio.h>
#include <limits.h>
#include <limits.h>
#include <pthread.h>
#include <pthread.h>
#include <unistd.h>
#include "magisk.h"
#include "magisk.h"
#include "utils.h"
#include "utils.h"
...
@@ -29,6 +30,7 @@ static void *logger_thread(void *args) {
...
@@ -29,6 +30,7 @@ static void *logger_thread(void *args) {
while
(
fdgets
(
buffer
,
sizeof
(
buffer
),
fd
))
{
while
(
fdgets
(
buffer
,
sizeof
(
buffer
),
fd
))
{
fprintf
(
logfile
,
"%s"
,
buffer
);
fprintf
(
logfile
,
"%s"
,
buffer
);
}
}
close
(
fd
);
return
NULL
;
return
NULL
;
}
}
...
...
jni/magisk.h
View file @
6017ff23
...
@@ -55,6 +55,7 @@ extern char *argv0; /* For changing process name */
...
@@ -55,6 +55,7 @@ extern char *argv0; /* For changing process name */
extern
char
*
applet
[];
extern
char
*
applet
[];
extern
int
(
*
applet_main
[])
(
int
,
char
*
[]);
extern
int
(
*
applet_main
[])
(
int
,
char
*
[]);
extern
int
null_fd
;
// Multi-call entrypoints
// Multi-call entrypoints
int
magiskhide_main
(
int
argc
,
char
*
argv
[]);
int
magiskhide_main
(
int
argc
,
char
*
argv
[]);
...
...
jni/utils/misc.c
View file @
6017ff23
...
@@ -45,17 +45,18 @@ unsigned get_radio_uid() {
...
@@ -45,17 +45,18 @@ unsigned get_radio_uid() {
}
}
int
check_data
()
{
int
check_data
()
{
int
ret
=
0
;
char
buffer
[
4096
];
char
buffer
[
4096
];
FILE
*
fp
=
xfopen
(
"/proc/mounts"
,
"r"
);
FILE
*
fp
=
xfopen
(
"/proc/mounts"
,
"r"
);
while
(
fgets
(
buffer
,
sizeof
(
buffer
),
fp
))
{
while
(
fgets
(
buffer
,
sizeof
(
buffer
),
fp
))
{
if
(
strstr
(
buffer
,
" /data "
))
{
if
(
strstr
(
buffer
,
" /data "
))
{
if
(
strstr
(
buffer
,
"tmpfs"
))
if
(
strstr
(
buffer
,
"tmpfs"
)
==
NULL
)
return
0
;
ret
=
1
;
else
break
;
return
1
;
}
}
}
}
return
0
;
fclose
(
fp
);
return
ret
;
}
}
/* All the string should be freed manually!! */
/* All the string should be freed manually!! */
...
@@ -238,10 +239,6 @@ int run_command(int *fd, const char *path, char *const argv[]) {
...
@@ -238,10 +239,6 @@ int run_command(int *fd, const char *path, char *const argv[]) {
xdup2
(
sv
[
0
],
STDIN_FILENO
);
xdup2
(
sv
[
0
],
STDIN_FILENO
);
xdup2
(
sv
[
0
],
STDOUT_FILENO
);
xdup2
(
sv
[
0
],
STDOUT_FILENO
);
xdup2
(
sv
[
0
],
STDERR_FILENO
);
xdup2
(
sv
[
0
],
STDERR_FILENO
);
}
else
{
close
(
STDIN_FILENO
);
close
(
STDOUT_FILENO
);
close
(
STDERR_FILENO
);
}
}
execv
(
path
,
argv
);
execv
(
path
,
argv
);
...
...
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