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
67845f9c
Unverified
Commit
67845f9c
authored
Jan 18, 2023
by
LoveSy
Committed by
GitHub
Jan 18, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clear sepolicy rules when disable/remove modules
Co-authored-by:
topjohnwu
<
topjohnwu@gmail.com
>
parent
f5627104
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
2 deletions
+25
-2
module.cpp
native/src/core/module.cpp
+25
-2
No files found.
native/src/core/module.cpp
View file @
67845f9c
...
...
@@ -779,17 +779,40 @@ void handle_modules() {
collect_modules
(
true
);
}
static
int
check_rules_dir
(
char
*
buf
,
size_t
sz
)
{
int
off
=
ssprintf
(
buf
,
sz
,
"%s/%s"
,
MAGISKTMP
.
data
(),
RULESDIR
);
struct
stat
st1
{};
struct
stat
st2
{};
if
(
xstat
(
buf
,
&
st1
)
<
0
||
xstat
(
MODULEROOT
,
&
st2
)
<
0
)
return
0
;
if
(
st1
.
st_dev
==
st2
.
st_dev
&&
st1
.
st_ino
==
st2
.
st_ino
)
return
0
;
return
off
;
}
void
disable_modules
()
{
foreach_module
([](
int
,
auto
,
int
modfd
)
{
char
buf
[
4096
];
int
off
=
check_rules_dir
(
buf
,
sizeof
(
buf
));
foreach_module
([
&
](
int
,
dirent
*
entry
,
int
modfd
)
{
close
(
xopenat
(
modfd
,
"disable"
,
O_RDONLY
|
O_CREAT
|
O_CLOEXEC
,
0
));
if
(
off
)
{
ssprintf
(
buf
+
off
,
sizeof
(
buf
)
-
off
,
"/%s/%s"
,
entry
->
d_name
,
"sepolicy.rule"
);
unlink
(
buf
);
}
});
}
void
remove_modules
()
{
foreach_module
([](
int
,
dirent
*
entry
,
int
)
{
char
buf
[
4096
];
int
off
=
check_rules_dir
(
buf
,
sizeof
(
buf
));
foreach_module
([
&
](
int
,
dirent
*
entry
,
int
)
{
auto
uninstaller
=
MODULEROOT
+
"/"
s
+
entry
->
d_name
+
"/uninstall.sh"
;
if
(
access
(
uninstaller
.
data
(),
F_OK
)
==
0
)
exec_script
(
uninstaller
.
data
());
if
(
off
)
{
ssprintf
(
buf
+
off
,
sizeof
(
buf
)
-
off
,
"/%s/%s"
,
entry
->
d_name
,
"sepolicy.rule"
);
unlink
(
buf
);
}
});
rm_rf
(
MODULEROOT
);
}
...
...
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