mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-22 16:07:39 +00:00
Allow running scripts with incomplete env
This commit is contained in:
parent
cfb20b0f86
commit
49f241b77c
@ -13,9 +13,10 @@ using namespace std;
|
|||||||
|
|
||||||
static const char *bbpath() {
|
static const char *bbpath() {
|
||||||
static string path;
|
static string path;
|
||||||
if (path.empty()) {
|
|
||||||
path = get_magisk_tmp();
|
path = get_magisk_tmp();
|
||||||
path += "/" BBPATH "/busybox";
|
path += "/" BBPATH "/busybox";
|
||||||
|
if (access(path.data(), X_OK) != 0) {
|
||||||
|
path = DATABIN "/busybox";
|
||||||
}
|
}
|
||||||
return path.data();
|
return path.data();
|
||||||
}
|
}
|
||||||
@ -210,7 +211,7 @@ static void abort(FILE *fp, const char *fmt, ...) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constexpr char install_module_script[] = R"EOF(
|
constexpr char install_module_script[] = R"EOF(
|
||||||
exec $(magisk --path)/.magisk/busybox/busybox sh -c '
|
exec %s sh -c '
|
||||||
. /data/adb/magisk/util_functions.sh
|
. /data/adb/magisk/util_functions.sh
|
||||||
install_module
|
install_module
|
||||||
exit 0'
|
exit 0'
|
||||||
@ -220,7 +221,7 @@ void install_module(const char *file) {
|
|||||||
if (getuid() != 0)
|
if (getuid() != 0)
|
||||||
abort(stderr, "Run this command with root");
|
abort(stderr, "Run this command with root");
|
||||||
if (access(DATABIN, F_OK) ||
|
if (access(DATABIN, F_OK) ||
|
||||||
access(DATABIN "/busybox", X_OK) ||
|
access(bbpath(), X_OK) ||
|
||||||
access(DATABIN "/util_functions.sh", F_OK))
|
access(DATABIN "/util_functions.sh", F_OK))
|
||||||
abort(stderr, "Incomplete Magisk install");
|
abort(stderr, "Incomplete Magisk install");
|
||||||
if (access(file, F_OK))
|
if (access(file, F_OK))
|
||||||
@ -236,7 +237,10 @@ void install_module(const char *file) {
|
|||||||
xdup2(fd, STDERR_FILENO);
|
xdup2(fd, STDERR_FILENO);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
const char *argv[] = { "/system/bin/sh", "-c", install_module_script, nullptr };
|
char cmds[256];
|
||||||
|
ssprintf(cmds, sizeof(cmds), install_module_script, bbpath());
|
||||||
|
|
||||||
|
const char *argv[] = { "/system/bin/sh", "-c", cmds, nullptr };
|
||||||
execve(argv[0], (char **) argv, environ);
|
execve(argv[0], (char **) argv, environ);
|
||||||
abort(stdout, "Failed to execute BusyBox shell");
|
abort(stdout, "Failed to execute BusyBox shell");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user