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
8277896c
Commit
8277896c
authored
Nov 01, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure uninstall.sh is executed on remove
parent
493068c0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
33 deletions
+46
-33
bootstages.cpp
native/jni/core/bootstages.cpp
+27
-0
daemon.cpp
native/jni/core/daemon.cpp
+0
-28
daemon.h
native/jni/include/daemon.h
+3
-4
misc.cpp
native/jni/utils/misc.cpp
+14
-0
misc.h
native/jni/utils/misc.h
+2
-1
No files found.
native/jni/core/bootstages.cpp
View file @
8277896c
...
@@ -449,6 +449,33 @@ static void prepare_modules() {
...
@@ -449,6 +449,33 @@ static void prepare_modules() {
chmod
(
SECURE_DIR
,
0700
);
chmod
(
SECURE_DIR
,
0700
);
}
}
static
void
reboot
()
{
if
(
RECOVERY_MODE
)
exec_command_sync
(
"/system/bin/reboot"
,
"recovery"
);
else
exec_command_sync
(
"/system/bin/reboot"
);
}
void
remove_modules
()
{
LOGI
(
"* Remove all modules and reboot"
);
chdir
(
MODULEROOT
);
rm_rf
(
"lost+found"
);
DIR
*
dir
=
xopendir
(
"."
);
struct
dirent
*
entry
;
while
((
entry
=
xreaddir
(
dir
)))
{
if
(
entry
->
d_type
==
DT_DIR
)
{
if
(
entry
->
d_name
==
"."
sv
||
entry
->
d_name
==
".."
sv
||
entry
->
d_name
==
".core"
sv
)
continue
;
chdir
(
entry
->
d_name
);
close
(
creat
(
"remove"
,
0644
));
chdir
(
".."
);
}
}
closedir
(
dir
);
chdir
(
"/"
);
reboot
();
}
static
void
collect_modules
()
{
static
void
collect_modules
()
{
chdir
(
MODULEROOT
);
chdir
(
MODULEROOT
);
rm_rf
(
"lost+found"
);
rm_rf
(
"lost+found"
);
...
...
native/jni/core/daemon.cpp
View file @
8277896c
...
@@ -31,13 +31,6 @@ static void verify_client(int client, pid_t pid) {
...
@@ -31,13 +31,6 @@ static void verify_client(int client, pid_t pid) {
}
}
}
}
static
void
remove_modules
()
{
LOGI
(
"* Remove all modules and reboot"
);
rm_rf
(
MODULEROOT
);
rm_rf
(
MODULEUPGRADE
);
reboot
();
}
static
void
*
request_handler
(
void
*
args
)
{
static
void
*
request_handler
(
void
*
args
)
{
int
client
=
reinterpret_cast
<
intptr_t
>
(
args
);
int
client
=
reinterpret_cast
<
intptr_t
>
(
args
);
...
@@ -179,27 +172,6 @@ static void main_daemon() {
...
@@ -179,27 +172,6 @@ static void main_daemon() {
}
}
}
}
void
reboot
()
{
if
(
RECOVERY_MODE
)
exec_command_sync
(
"/system/bin/reboot"
,
"recovery"
);
else
exec_command_sync
(
"/system/bin/reboot"
);
}
int
switch_mnt_ns
(
int
pid
)
{
char
mnt
[
32
];
snprintf
(
mnt
,
sizeof
(
mnt
),
"/proc/%d/ns/mnt"
,
pid
);
if
(
access
(
mnt
,
R_OK
)
==
-
1
)
return
1
;
// Maybe process died..
int
fd
,
ret
;
fd
=
xopen
(
mnt
,
O_RDONLY
);
if
(
fd
<
0
)
return
1
;
// Switch to its namespace
ret
=
xsetns
(
fd
,
0
);
close
(
fd
);
return
ret
;
}
int
connect_daemon
(
bool
create
)
{
int
connect_daemon
(
bool
create
)
{
struct
sockaddr_un
sun
;
struct
sockaddr_un
sun
;
socklen_t
len
=
setup_sockaddr
(
&
sun
,
MAIN_SOCKET
);
socklen_t
len
=
setup_sockaddr
(
&
sun
,
MAIN_SOCKET
);
...
...
native/jni/include/daemon.h
View file @
8277896c
...
@@ -30,13 +30,11 @@ enum {
...
@@ -30,13 +30,11 @@ enum {
DAEMON_LAST
DAEMON_LAST
};
};
// daemon.c
// daemon.c
pp
int
connect_daemon
(
bool
create
=
false
);
int
connect_daemon
(
bool
create
=
false
);
int
switch_mnt_ns
(
int
pid
);
void
reboot
();
// socket.c
// socket.c
pp
socklen_t
setup_sockaddr
(
struct
sockaddr_un
*
sun
,
const
char
*
name
);
socklen_t
setup_sockaddr
(
struct
sockaddr_un
*
sun
,
const
char
*
name
);
int
create_rand_socket
(
struct
sockaddr_un
*
sun
);
int
create_rand_socket
(
struct
sockaddr_un
*
sun
);
...
@@ -63,6 +61,7 @@ void unlock_blocks();
...
@@ -63,6 +61,7 @@ void unlock_blocks();
void
post_fs_data
(
int
client
);
void
post_fs_data
(
int
client
);
void
late_start
(
int
client
);
void
late_start
(
int
client
);
void
boot_complete
(
int
client
);
void
boot_complete
(
int
client
);
void
remove_modules
();
/*************
/*************
* Scripting *
* Scripting *
...
...
native/jni/utils/misc.cpp
View file @
8277896c
...
@@ -198,3 +198,17 @@ uint32_t binary_gcd(uint32_t u, uint32_t v) {
...
@@ -198,3 +198,17 @@ uint32_t binary_gcd(uint32_t u, uint32_t v) {
}
while
(
v
!=
0
);
}
while
(
v
!=
0
);
return
u
<<
shift
;
return
u
<<
shift
;
}
}
int
switch_mnt_ns
(
int
pid
)
{
char
mnt
[
32
];
snprintf
(
mnt
,
sizeof
(
mnt
),
"/proc/%d/ns/mnt"
,
pid
);
if
(
access
(
mnt
,
R_OK
)
==
-
1
)
return
1
;
// Maybe process died..
int
fd
,
ret
;
fd
=
xopen
(
mnt
,
O_RDONLY
);
if
(
fd
<
0
)
return
1
;
// Switch to its namespace
ret
=
xsetns
(
fd
,
0
);
close
(
fd
);
return
ret
;
}
native/jni/utils/misc.h
View file @
8277896c
...
@@ -15,6 +15,7 @@ void init_argv0(int argc, char **argv);
...
@@ -15,6 +15,7 @@ void init_argv0(int argc, char **argv);
void
set_nice_name
(
const
char
*
name
);
void
set_nice_name
(
const
char
*
name
);
int
parse_int
(
const
char
*
s
);
int
parse_int
(
const
char
*
s
);
uint32_t
binary_gcd
(
uint32_t
u
,
uint32_t
v
);
uint32_t
binary_gcd
(
uint32_t
u
,
uint32_t
v
);
int
switch_mnt_ns
(
int
pid
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
@@ -96,4 +97,4 @@ int exec_command_sync(Args &&...args) {
...
@@ -96,4 +97,4 @@ int exec_command_sync(Args &&...args) {
bool
ends_with
(
const
std
::
string_view
&
s1
,
const
std
::
string_view
&
s2
);
bool
ends_with
(
const
std
::
string_view
&
s1
,
const
std
::
string_view
&
s2
);
#endif
#endif
\ No newline at end of file
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