mirror of
https://github.com/topjohnwu/Magisk.git
synced 2026-01-02 07:51:07 -08:00
Stop embedding magisk in magiskinit
This commit is contained in:
@@ -10,12 +10,6 @@
|
||||
#include <utils.hpp>
|
||||
|
||||
#include "binaries.h"
|
||||
#ifdef USE_64BIT
|
||||
#include "binaries_arch64.h"
|
||||
#else
|
||||
#include "binaries_arch.h"
|
||||
#endif
|
||||
|
||||
#include "init.hpp"
|
||||
|
||||
using namespace std;
|
||||
@@ -26,7 +20,7 @@ using namespace std;
|
||||
constexpr int (*init_applet_main[])(int, char *[]) =
|
||||
{ magiskpolicy_main, magiskpolicy_main, nullptr };
|
||||
|
||||
static bool unxz(int fd, const uint8_t *buf, size_t size) {
|
||||
bool unxz(int fd, const uint8_t *buf, size_t size) {
|
||||
uint8_t out[8192];
|
||||
xz_crc32_init();
|
||||
struct xz_dec *dec = xz_dec_init(XZ_DYNALLOC, 1 << 26);
|
||||
@@ -49,16 +43,6 @@ static bool unxz(int fd, const uint8_t *buf, size_t size) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int dump_magisk(const char *path, mode_t mode) {
|
||||
int fd = xopen(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, mode);
|
||||
if (fd < 0)
|
||||
return 1;
|
||||
if (!unxz(fd, magisk_xz, sizeof(magisk_xz)))
|
||||
return 1;
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static 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)
|
||||
@@ -147,10 +131,9 @@ int main(int argc, char *argv[]) {
|
||||
#endif
|
||||
|
||||
if (argc > 1 && argv[1] == "-x"sv) {
|
||||
if (argv[2] == "magisk"sv)
|
||||
return dump_magisk(argv[3], 0755);
|
||||
else if (argv[2] == "manager"sv)
|
||||
if (argc > 2 && argv[2] == "manager"sv)
|
||||
return dump_manager(argv[3], 0644);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (getpid() != 1)
|
||||
@@ -166,18 +149,16 @@ int main(int argc, char *argv[]) {
|
||||
// This will also mount /sys and /proc
|
||||
load_kernel_info(&cmd);
|
||||
|
||||
if (cmd.skip_initramfs) {
|
||||
if (cmd.skip_initramfs)
|
||||
init = new SARInit(argv, &cmd);
|
||||
} else {
|
||||
if (cmd.force_normal_boot)
|
||||
init = new FirstStageInit(argv, &cmd);
|
||||
else if (access("/sbin/recovery", F_OK) == 0 || access("/system/bin/recovery", F_OK) == 0)
|
||||
init = new RecoveryInit(argv, &cmd);
|
||||
else if (check_two_stage())
|
||||
init = new FirstStageInit(argv, &cmd);
|
||||
else
|
||||
init = new RootFSInit(argv, &cmd);
|
||||
}
|
||||
else if (cmd.force_normal_boot)
|
||||
init = new FirstStageInit(argv, &cmd);
|
||||
else if (access("/sbin/recovery", F_OK) == 0 || access("/system/bin/recovery", F_OK) == 0)
|
||||
init = new RecoveryInit(argv, &cmd);
|
||||
else if (check_two_stage())
|
||||
init = new FirstStageInit(argv, &cmd);
|
||||
else
|
||||
init = new RootFSInit(argv, &cmd);
|
||||
}
|
||||
|
||||
// Run the main routine
|
||||
|
||||
Reference in New Issue
Block a user