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
9de6e884
Commit
9de6e884
authored
Mar 17, 2022
by
vvb2060
Committed by
John Wu
Apr 08, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dump stub app to MAGISKTMP/stub.apk
parent
01a12134
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
5 deletions
+20
-5
bootstages.cpp
native/jni/core/bootstages.cpp
+14
-4
init.cpp
native/jni/init/init.cpp
+1
-1
init.hpp
native/jni/init/init.hpp
+1
-0
rootdir.cpp
native/jni/init/rootdir.cpp
+4
-0
No files found.
native/jni/core/bootstages.cpp
View file @
9de6e884
...
...
@@ -18,6 +18,7 @@
using
namespace
std
;
static
bool
safe_mode
=
false
;
static
int
stub_fd
=
-
1
;
bool
zygisk_enabled
=
false
;
/*********
...
...
@@ -122,6 +123,10 @@ static bool magisk_env() {
LOGI
(
"* Initializing Magisk environment
\n
"
);
string
stub_path
=
MAGISKTMP
+
"/stub.apk"
;
stub_fd
=
xopen
(
stub_path
.
data
(),
O_RDONLY
|
O_CLOEXEC
);
unlink
(
stub_path
.
data
());
string
pkg
;
get_manager
(
&
pkg
);
...
...
@@ -370,10 +375,15 @@ void boot_complete(int client) {
if
(
access
(
SECURE_DIR
,
F_OK
)
!=
0
)
xmkdir
(
SECURE_DIR
,
0700
);
if
(
!
get_manager
())
{
if
(
stub_fd
>
0
&&
!
get_manager
())
{
// Install stub
auto
init
=
MAGISKTMP
+
"/magiskinit"
;
exec_command_sync
(
init
.
data
(),
"-x"
,
"manager"
,
"/data/magisk.apk"
);
install_apk
(
"/data/magisk.apk"
);
struct
stat
st
{};
fstat
(
stub_fd
,
&
st
);
int
dfd
=
xopen
(
"/data/stub.apk"
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
|
O_CLOEXEC
,
0600
);
xsendfile
(
dfd
,
stub_fd
,
nullptr
,
st
.
st_size
);
close
(
stub_fd
);
close
(
dfd
);
stub_fd
=
-
1
;
install_apk
(
"/data/stub.apk"
);
}
}
native/jni/init/init.cpp
View file @
9de6e884
...
...
@@ -35,7 +35,7 @@ bool unxz(int fd, const uint8_t *buf, size_t size) {
return
true
;
}
static
int
dump_manager
(
const
char
*
path
,
mode_t
mode
)
{
int
dump_manager
(
const
char
*
path
,
mode_t
mode
)
{
int
fd
=
xopen
(
path
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
|
O_CLOEXEC
,
mode
);
if
(
fd
<
0
)
return
1
;
...
...
native/jni/init/init.hpp
View file @
9de6e884
...
...
@@ -32,6 +32,7 @@ void load_kernel_info(BootConfig *config);
bool
check_two_stage
();
void
setup_klog
();
const
char
*
backup_init
();
int
dump_manager
(
const
char
*
path
,
mode_t
mode
);
/***************
* Base classes
...
...
native/jni/init/rootdir.cpp
View file @
9de6e884
...
...
@@ -233,6 +233,8 @@ void SARBase::patch_ro_root() {
}
else
{
xsymlink
(
"./magisk32"
,
"magisk"
);
}
dump_manager
(
"stub.apk"
,
0644
);
}
if
((
access
(
SPLIT_PLAT_CIL
,
F_OK
)
!=
0
&&
access
(
"/sepolicy"
,
F_OK
)
==
0
)
||
!
hijack_sepolicy
())
{
...
...
@@ -305,6 +307,8 @@ void MagiskInit::patch_rw_root() {
}
else
{
xsymlink
(
"./magisk32"
,
"magisk"
);
}
dump_manager
(
"stub.apk"
,
0644
);
}
if
((
!
treble
&&
access
(
"/sepolicy"
,
F_OK
)
==
0
)
||
!
hijack_sepolicy
())
{
...
...
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