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
dead7480
Commit
dead7480
authored
Dec 04, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Setup log file when manually starting daemon
parent
ab207a1b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
7 deletions
+12
-7
daemon.cpp
native/jni/core/daemon.cpp
+9
-5
magisk.cpp
native/jni/core/magisk.cpp
+1
-1
daemon.hpp
native/jni/include/daemon.hpp
+2
-1
No files found.
native/jni/core/daemon.cpp
View file @
dead7480
...
...
@@ -25,7 +25,7 @@ int DAEMON_STATE = STATE_UNKNOWN;
static
struct
stat
self_st
;
static
bool
verify_client
(
int
client
,
pid_t
pid
)
{
static
bool
verify_client
(
pid_t
pid
)
{
// Verify caller is the same as server
char
path
[
32
];
sprintf
(
path
,
"/proc/%d/exe"
,
pid
);
...
...
@@ -71,11 +71,14 @@ static void handle_request(int client) {
// Verify client credentials
ucred
cred
;
get_client_cred
(
client
,
&
cred
);
if
(
cred
.
uid
!=
0
&&
!
verify_client
(
c
lient
,
c
red
.
pid
))
if
(
cred
.
uid
!=
0
&&
!
verify_client
(
cred
.
pid
))
goto
shortcut
;
// Check client permissions
req_code
=
read_int
(
client
);
if
(
req_code
<
0
||
req_code
>=
DAEMON_CODE_END
)
goto
shortcut
;
// Check client permissions
switch
(
req_code
)
{
case
MAGISKHIDE
:
case
POST_FS_DATA
:
...
...
@@ -108,7 +111,7 @@ static void handle_request(int client) {
DAEMON_STATE
=
STATE_BOOT_COMPLETE
;
break
;
// Simple requests
to query daemon info
// Simple requests
case
CHECK_VERSION
:
write_string
(
client
,
MAGISK_VERSION
":MAGISK"
);
goto
shortcut
;
...
...
@@ -118,7 +121,8 @@ static void handle_request(int client) {
case
GET_PATH
:
write_string
(
client
,
MAGISKTMP
.
data
());
goto
shortcut
;
case
DO_NOTHING
:
case
START_DAEMON
:
setup_logfile
(
true
);
goto
shortcut
;
}
...
...
native/jni/core/magisk.cpp
View file @
dead7480
...
...
@@ -81,7 +81,7 @@ int magisk_main(int argc, char *argv[]) {
return
0
;
}
else
if
(
argv
[
1
]
==
"--daemon"
sv
)
{
int
fd
=
connect_daemon
(
true
);
write_int
(
fd
,
DO_NOTHING
);
write_int
(
fd
,
START_DAEMON
);
return
0
;
}
else
if
(
argv
[
1
]
==
"--post-fs-data"
sv
)
{
int
fd
=
connect_daemon
(
true
);
...
...
native/jni/include/daemon.hpp
View file @
dead7480
...
...
@@ -8,7 +8,7 @@
// Daemon command codes
enum
{
DO_NOTHING
=
0
,
START_DAEMON
,
SUPERUSER
,
CHECK_VERSION
,
CHECK_VERSION_CODE
,
...
...
@@ -19,6 +19,7 @@ enum {
SQLITE_CMD
,
REMOVE_MODULES
,
GET_PATH
,
DAEMON_CODE_END
,
};
// Return codes for 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