mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-05-01 23:14:26 +02:00
core: search for first available dir in PATH
This commit is contained in:
parent
9a74e19117
commit
4d80361805
@ -233,10 +233,21 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void inject_magisk_bins(root_node *system) {
|
static void inject_magisk_bins(root_node *system) {
|
||||||
auto bin = system->get_child<inter_node>("bin");
|
dir_node* bin = system->get_child<inter_node>("bin");
|
||||||
if (!bin) {
|
if (!bin) {
|
||||||
bin = new inter_node("bin");
|
struct stat st{};
|
||||||
system->insert(bin);
|
bin = system;
|
||||||
|
for (auto &item: split(getenv("PATH"), ":")) {
|
||||||
|
item.erase(0, item.starts_with("/system/") ? 8 : 1);
|
||||||
|
auto system_path = "/system/" + item;
|
||||||
|
if (stat(system_path.data(), &st) == 0 && st.st_mode & S_IXOTH) {
|
||||||
|
for (const auto &dir: split(item, "/")) {
|
||||||
|
auto node = bin->get_child<inter_node>(dir);
|
||||||
|
bin = node ? node : bin->emplace<inter_node>(dir, dir.data());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert binaries
|
// Insert binaries
|
||||||
|
Loading…
x
Reference in New Issue
Block a user