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
5fd574a1
Commit
5fd574a1
authored
Apr 30, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix --remove-modules command
parent
03c10538
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
59 deletions
+46
-59
bootstages.cpp
native/jni/core/bootstages.cpp
+1
-21
daemon.cpp
native/jni/core/daemon.cpp
+10
-6
module.cpp
native/jni/core/module.cpp
+20
-0
daemon.hpp
native/jni/include/daemon.hpp
+14
-32
hide_utils.cpp
native/jni/magiskhide/hide_utils.cpp
+1
-0
No files found.
native/jni/core/bootstages.cpp
View file @
5fd574a1
...
@@ -19,12 +19,9 @@
...
@@ -19,12 +19,9 @@
using
namespace
std
;
using
namespace
std
;
extern
vector
<
string
>
module_list
;
static
bool
no_secure_dir
=
false
;
static
bool
no_secure_dir
=
false
;
static
bool
pfs_done
=
false
;
static
bool
pfs_done
=
false
;
extern
void
auto_start_magiskhide
();
/*********
/*********
* Setup *
* Setup *
*********/
*********/
...
@@ -139,30 +136,13 @@ static bool magisk_env() {
...
@@ -139,30 +136,13 @@ static bool magisk_env() {
return
true
;
return
true
;
}
}
static
void
reboot
()
{
void
reboot
()
{
if
(
RECOVERY_MODE
)
if
(
RECOVERY_MODE
)
exec_command_sync
(
"/system/bin/reboot"
,
"recovery"
);
exec_command_sync
(
"/system/bin/reboot"
,
"recovery"
);
else
else
exec_command_sync
(
"/system/bin/reboot"
);
exec_command_sync
(
"/system/bin/reboot"
);
}
}
void
remove_modules
()
{
LOGI
(
"* Remove all modules and reboot"
);
auto
dir
=
xopen_dir
(
MODULEROOT
);
int
dfd
=
dirfd
(
dir
.
get
());
for
(
dirent
*
entry
;
(
entry
=
xreaddir
(
dir
.
get
()));)
{
if
(
entry
->
d_type
==
DT_DIR
)
{
if
(
entry
->
d_name
==
".core"
sv
)
continue
;
int
modfd
=
xopenat
(
dfd
,
entry
->
d_name
,
O_RDONLY
|
O_CLOEXEC
);
close
(
xopenat
(
modfd
,
"remove"
,
O_RDONLY
|
O_CREAT
|
O_CLOEXEC
));
close
(
modfd
);
}
}
reboot
();
}
static
bool
check_data
()
{
static
bool
check_data
()
{
bool
mnt
=
false
;
bool
mnt
=
false
;
bool
data
=
false
;
bool
data
=
false
;
...
...
native/jni/core/daemon.cpp
View file @
5fd574a1
...
@@ -56,6 +56,14 @@ static void *request_handler(void *args) {
...
@@ -56,6 +56,14 @@ static void *request_handler(void *args) {
close
(
client
);
close
(
client
);
return
nullptr
;
return
nullptr
;
}
}
break
;
case
REMOVE_MODULES
:
if
(
credential
.
uid
!=
UID_SHELL
&&
credential
.
uid
!=
UID_ROOT
)
{
write_int
(
client
,
1
);
close
(
client
);
return
nullptr
;
}
break
;
default:
default:
break
;
break
;
}
}
...
@@ -88,12 +96,8 @@ static void *request_handler(void *args) {
...
@@ -88,12 +96,8 @@ static void *request_handler(void *args) {
exec_sql
(
client
);
exec_sql
(
client
);
break
;
break
;
case
REMOVE_MODULES
:
case
REMOVE_MODULES
:
if
(
credential
.
uid
==
UID_SHELL
||
credential
.
uid
==
UID_ROOT
)
{
remove_modules
();
remove_modules
();
write_int
(
client
,
0
);
write_int
(
client
,
0
);
}
else
{
write_int
(
client
,
1
);
}
close
(
client
);
close
(
client
);
break
;
break
;
case
GET_PATH
:
case
GET_PATH
:
...
...
native/jni/core/module.cpp
View file @
5fd574a1
...
@@ -686,3 +686,23 @@ void handle_modules() {
...
@@ -686,3 +686,23 @@ void handle_modules() {
mount_modules
();
mount_modules
();
}
}
void
remove_modules
()
{
LOGI
(
"* Remove all modules and reboot
\n
"
);
auto
dir
=
open_dir
(
MODULEROOT
);
if
(
!
dir
)
return
;
int
dfd
=
dirfd
(
dir
.
get
());
for
(
dirent
*
entry
;
(
entry
=
xreaddir
(
dir
.
get
()));)
{
if
(
entry
->
d_type
==
DT_DIR
)
{
if
(
entry
->
d_name
==
".core"
sv
)
continue
;
int
modfd
=
xopenat
(
dfd
,
entry
->
d_name
,
O_RDONLY
|
O_CLOEXEC
);
close
(
xopenat
(
modfd
,
"remove"
,
O_RDONLY
|
O_CREAT
|
O_CLOEXEC
,
0
));
close
(
modfd
);
}
}
reboot
();
}
native/jni/include/daemon.hpp
View file @
5fd574a1
...
@@ -29,46 +29,28 @@ enum {
...
@@ -29,46 +29,28 @@ enum {
DAEMON_LAST
DAEMON_LAST
};
};
// daemon.cpp
extern
int
SDK_INT
;
extern
bool
RECOVERY_MODE
;
int
connect_daemon
(
bool
create
=
false
);
extern
std
::
vector
<
std
::
string
>
module_list
;
#define APP_DATA_DIR (SDK_INT >= 24 ? "/data/user_de" : "/data/user")
/***************
* Boot Stages *
***************/
void
unlock_blocks
();
// Daemon handlers
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
handle_modules
();
void
magiskhide_handler
(
int
client
);
void
su_daemon_handler
(
int
client
,
struct
ucred
*
credential
);
void
remove_modules
();
void
remove_modules
();
/*************
// Misc
* Scripting *
int
connect_daemon
(
bool
create
=
false
);
*************/
void
auto_start_magiskhide
();
void
unlock_blocks
();
void
handle_modules
();
void
reboot
();
// Scripting
void
exec_script
(
const
char
*
script
);
void
exec_script
(
const
char
*
script
);
void
exec_common_script
(
const
char
*
stage
);
void
exec_common_script
(
const
char
*
stage
);
void
exec_module_script
(
const
char
*
stage
,
const
std
::
vector
<
std
::
string
>
&
module_list
);
void
exec_module_script
(
const
char
*
stage
,
const
std
::
vector
<
std
::
string
>
&
module_list
);
void
install_apk
(
const
char
*
apk
);
void
install_apk
(
const
char
*
apk
);
/**************
* MagiskHide *
**************/
void
magiskhide_handler
(
int
client
);
/*************
* Superuser *
*************/
void
su_daemon_handler
(
int
client
,
struct
ucred
*
credential
);
/*********************
* Daemon Global Vars
*********************/
extern
int
SDK_INT
;
extern
bool
RECOVERY_MODE
;
#define APP_DATA_DIR (SDK_INT >= 24 ? "/data/user_de" : "/data/user")
native/jni/magiskhide/hide_utils.cpp
View file @
5fd574a1
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include <magisk.hpp>
#include <magisk.hpp>
#include <utils.hpp>
#include <utils.hpp>
#include <db.hpp>
#include <db.hpp>
#include <daemon.hpp>
#include "magiskhide.hpp"
#include "magiskhide.hpp"
...
...
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