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
2dd4cf04
Commit
2dd4cf04
authored
Oct 14, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent multiple process clashes to start daemon
parent
d1b9eca5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
daemon.c
jni/daemon/daemon.c
+13
-12
No files found.
jni/daemon/daemon.c
View file @
2dd4cf04
...
...
@@ -137,6 +137,18 @@ void start_daemon() {
xdup2
(
fd
,
STDERR_FILENO
);
close
(
fd
);
// Patch selinux with medium patch before we do anything
load_policydb
(
SELINUX_POLICY
);
sepol_med_rules
();
dump_policydb
(
SELINUX_LOAD
);
struct
sockaddr_un
sun
;
fd
=
setup_socket
(
&
sun
);
if
(
xbind
(
fd
,
(
struct
sockaddr
*
)
&
sun
,
sizeof
(
sun
))
==
-
1
)
exit
(
1
);
xlisten
(
fd
,
10
);
if
((
is_restart
=
access
(
UNBLOCKFILE
,
F_OK
)
==
0
))
{
// Restart stuffs if the daemon is restarted
exec_command_sync
(
"logcat"
,
"-b"
,
"all"
,
"-c"
,
NULL
);
...
...
@@ -147,21 +159,10 @@ void start_daemon() {
// 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
();
dump_policydb
(
SELINUX_LOAD
);
// Continue the larger patch in another thread, we will join later
xpthread_create
(
&
sepol_patch
,
NULL
,
large_sepol_patch
,
NULL
);
struct
sockaddr_un
sun
;
fd
=
setup_socket
(
&
sun
);
xbind
(
fd
,
(
struct
sockaddr
*
)
&
sun
,
sizeof
(
sun
));
xlisten
(
fd
,
10
);
LOGI
(
"Magisk v"
xstr
(
MAGISK_VERSION
)
"("
xstr
(
MAGISK_VER_CODE
)
") daemon started
\n
"
);
// Change process name
strcpy
(
argv0
,
"magisk_daemon"
);
...
...
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