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
6abd9aa8
Commit
6abd9aa8
authored
Sep 26, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new --install-module command
Close #2253
parent
c91ebfbc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
1 deletion
+42
-1
magisk.cpp
native/jni/core/magisk.cpp
+4
-1
scripting.cpp
native/jni/core/scripting.cpp
+37
-0
daemon.hpp
native/jni/include/daemon.hpp
+1
-0
No files found.
native/jni/core/magisk.cpp
View file @
6abd9aa8
...
@@ -21,10 +21,11 @@ Options:
...
@@ -21,10 +21,11 @@ Options:
-v print running daemon version
-v print running daemon version
-V print running daemon version code
-V print running daemon version code
--list list all available applets
--list list all available applets
--daemon manually start magisk daemon
--remove-modules remove all modules and reboot
--remove-modules remove all modules and reboot
--install-module ZIP install a module zip file
Advanced Options (Internal APIs):
Advanced Options (Internal APIs):
--daemon manually start magisk daemon
--[init trigger] start service for init trigger
--[init trigger] start service for init trigger
Supported init triggers:
Supported init triggers:
post-fs-data, service, boot-complete
post-fs-data, service, boot-complete
...
@@ -116,6 +117,8 @@ int magisk_main(int argc, char *argv[]) {
...
@@ -116,6 +117,8 @@ int magisk_main(int argc, char *argv[]) {
char
*
path
=
read_string
(
fd
);
char
*
path
=
read_string
(
fd
);
printf
(
"%s
\n
"
,
path
);
printf
(
"%s
\n
"
,
path
);
return
0
;
return
0
;
}
else
if
(
argc
>=
3
&&
argv
[
1
]
==
"--install-module"
sv
)
{
install_module
(
argv
[
2
]);
}
}
#if 0
#if 0
/* Entry point for testing stuffs */
/* Entry point for testing stuffs */
...
...
native/jni/core/scripting.cpp
View file @
6abd9aa8
...
@@ -92,3 +92,40 @@ void install_apk(const char *apk) {
...
@@ -92,3 +92,40 @@ void install_apk(const char *apk) {
sprintf
(
cmds
,
install_script
,
apk
);
sprintf
(
cmds
,
install_script
,
apk
);
exec_command_sync
(
exec
,
BBEXEC_CMD
,
"-c"
,
cmds
);
exec_command_sync
(
exec
,
BBEXEC_CMD
,
"-c"
,
cmds
);
}
}
[[
noreturn
]]
static
void
abort
(
const
char
*
msg
)
{
fprintf
(
stderr
,
"%s
\n\n
"
,
msg
);
exit
(
1
);
}
constexpr
char
install_module_script
[]
=
R"EOF(
. /data/adb/magisk/util_functions.sh
install_module
exit 0
)EOF"
;
void
install_module
(
const
char
*
file
)
{
if
(
getuid
()
!=
0
)
abort
(
"Run this command with root"
);
if
(
access
(
DATABIN
,
F_OK
)
||
access
(
DATABIN
"/busybox"
,
X_OK
)
||
access
(
DATABIN
"/util_functions.sh"
,
F_OK
))
abort
(
"Incomplete Magisk install"
);
if
(
access
(
file
,
F_OK
))
{
char
msg
[
4096
];
sprintf
(
msg
,
"'%s' does not exist"
,
file
);
abort
(
msg
);
}
setenv
(
"OUTFD"
,
"1"
,
true
);
setenv
(
"ZIPFILE"
,
file
,
true
);
setenv
(
"ASH_STANDALONE"
,
"1"
,
1
);
int
fd
=
xopen
(
"/dev/null"
,
O_RDONLY
);
xdup2
(
fd
,
STDERR_FILENO
);
close
(
fd
);
const
char
*
argv
[]
=
{
BBEXEC_CMD
,
"-c"
,
install_module_script
};
execve
(
argv
[
0
],
(
char
**
)
argv
,
environ
);
abort
(
"Failed to execute BusyBox shell"
);
}
native/jni/include/daemon.hpp
View file @
6abd9aa8
...
@@ -69,3 +69,4 @@ void exec_script(const char *script);
...
@@ -69,3 +69,4 @@ void exec_script(const char *script);
void
exec_common_scripts
(
const
char
*
stage
);
void
exec_common_scripts
(
const
char
*
stage
);
void
exec_module_scripts
(
const
char
*
stage
,
const
std
::
vector
<
std
::
string
>
&
module_list
);
void
exec_module_scripts
(
const
char
*
stage
,
const
std
::
vector
<
std
::
string
>
&
module_list
);
void
install_apk
(
const
char
*
apk
);
void
install_apk
(
const
char
*
apk
);
[[
noreturn
]]
void
install_module
(
const
char
*
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