You've already forked Zygisk-Assistant
mirror of
https://github.com/snake-4/Zygisk-Assistant.git
synced 2025-09-06 06:37:02 +00:00
Updated logs and remount logic
This commit is contained in:
@@ -62,12 +62,13 @@ public:
|
|||||||
uint32_t flags = api->getFlags();
|
uint32_t flags = api->getFlags();
|
||||||
bool isRoot = (flags & zygisk::StateFlag::PROCESS_GRANTED_ROOT) != 0;
|
bool isRoot = (flags & zygisk::StateFlag::PROCESS_GRANTED_ROOT) != 0;
|
||||||
bool isOnDenylist = (flags & zygisk::StateFlag::PROCESS_ON_DENYLIST) != 0;
|
bool isOnDenylist = (flags & zygisk::StateFlag::PROCESS_ON_DENYLIST) != 0;
|
||||||
|
bool isChildZygote = args->is_child_zygote != NULL && *args->is_child_zygote;
|
||||||
if (isRoot || !isOnDenylist || !isUserAppUID(args->uid))
|
if (isRoot || !isOnDenylist || !isUserAppUID(args->uid))
|
||||||
{
|
{
|
||||||
LOGD("Skipping pid=%d ppid=%d uid=%d", getpid(), getppid(), args->uid);
|
LOGD("Skipping ppid=%d uid=%d isChildZygote=%d", getppid(), args->uid, isChildZygote);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOGD("Processing pid=%d ppid=%d uid=%d", getpid(), getppid(), args->uid);
|
LOGD("Processing ppid=%d uid=%d isChildZygote=%d", getppid(), args->uid, isChildZygote);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the comment above unshare hook.
|
* Read the comment above unshare hook.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <array>
|
#include <set>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
|
|
||||||
@@ -10,17 +11,22 @@
|
|||||||
#include "mountinfo_parser.hpp"
|
#include "mountinfo_parser.hpp"
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
|
|
||||||
constexpr std::array<const char *, 4> fsname_list = {"KSU", "APatch", "magisk", "worker"};
|
static const std::set<std::string> fsname_list = {"KSU", "APatch", "magisk", "worker"};
|
||||||
|
static const std::unordered_map<std::string, int> mount_flags_procfs = {
|
||||||
|
{"nosuid", MS_NOSUID},
|
||||||
|
{"nodev", MS_NODEV},
|
||||||
|
{"noexec", MS_NOEXEC},
|
||||||
|
{"noatime", MS_NOATIME},
|
||||||
|
{"nodiratime", MS_NODIRATIME},
|
||||||
|
{"relatime", MS_RELATIME},
|
||||||
|
{"nosymfollow", MS_NOSYMFOLLOW}};
|
||||||
|
|
||||||
static bool shouldUnmount(const mountinfo_entry_t &mount_info)
|
static bool shouldUnmount(const mountinfo_entry_t &mount_info)
|
||||||
{
|
{
|
||||||
const auto &root = mount_info.getRoot();
|
const auto &root = mount_info.getRoot();
|
||||||
|
|
||||||
// Unmount all module bind mounts
|
// Unmount all module bind mounts
|
||||||
if (root.rfind("/adb/", 0) == 0)
|
return root.starts_with("/adb/");
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool shouldUnmount(const mount_entry_t &mount)
|
static bool shouldUnmount(const mount_entry_t &mount)
|
||||||
@@ -34,24 +40,19 @@ static bool shouldUnmount(const mount_entry_t &mount)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Unmount all module overlayfs and tmpfs
|
// Unmount all module overlayfs and tmpfs
|
||||||
bool doesFsnameMatch = std::find(fsname_list.begin(), fsname_list.end(), mount.getFsName()) != fsname_list.end();
|
if ((type == "overlay" || type == "tmpfs") && fsname_list.contains(mount.getFsName()))
|
||||||
if ((type == "overlay" || type == "tmpfs") && doesFsnameMatch)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Unmount all overlayfs with lowerdir/upperdir/workdir starting with /data/adb
|
// Unmount all overlayfs with lowerdir/upperdir/workdir starting with /data/adb
|
||||||
if (type == "overlay")
|
if (type == "overlay")
|
||||||
{
|
{
|
||||||
const auto &lowerdir = options.find("lowerdir");
|
if (options.contains("lowerdir") && options.at("lowerdir").starts_with("/data/adb"))
|
||||||
const auto &upperdir = options.find("upperdir");
|
|
||||||
const auto &workdir = options.find("workdir");
|
|
||||||
|
|
||||||
if (lowerdir != options.end() && lowerdir->second.rfind("/data/adb", 0) == 0)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (upperdir != options.end() && upperdir->second.rfind("/data/adb", 0) == 0)
|
if (options.contains("upperdir") && options.at("upperdir").starts_with("/data/adb"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (workdir != options.end() && workdir->second.rfind("/data/adb", 0) == 0)
|
if (options.contains("workdir") && options.at("workdir").starts_with("/data/adb"))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,10 +108,23 @@ void doRemount()
|
|||||||
const auto &options = data_mount_it->getOptions();
|
const auto &options = data_mount_it->getOptions();
|
||||||
|
|
||||||
// If errors=remount-ro, remount it with errors=continue
|
// If errors=remount-ro, remount it with errors=continue
|
||||||
if (options.find("errors") != options.end() && options.at("errors") == "remount-ro")
|
if (options.contains("errors") && options.at("errors") == "remount-ro")
|
||||||
{
|
{
|
||||||
LOGD("Trying to remount: /data");
|
unsigned long flags = MS_REMOUNT;
|
||||||
ASSERT_LOG("doRemount", mount(NULL, "/data", NULL, MS_REMOUNT, "errors=continue") == 0);
|
for (const auto &flagName : mount_flags_procfs)
|
||||||
|
{
|
||||||
|
if (options.contains(flagName.first))
|
||||||
|
flags |= flagName.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mount(NULL, "/data", NULL, flags, "errors=continue") == 0)
|
||||||
|
{
|
||||||
|
LOGD("mount(NULL, \"/data\", NULL, 0x%lx, \"errors=continue\") returned 0", flags);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOGW("mount(NULL, \"/data\", NULL, 0x%lx, \"errors=continue\") returned -1: %d (%s)", flags, errno, strerror(errno));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user