Support MagiskHide when /sbin does not exist

This commit is contained in:
topjohnwu 2020-04-18 23:45:00 -07:00
parent 4c959cd983
commit 1e714af3cf
3 changed files with 20 additions and 16 deletions

View File

@ -87,13 +87,14 @@ void hide_unmount(int pid) {
vector<string> targets;
// Unmount dummy skeletons and /sbin links
targets.push_back(MAGISKTMP);
parse_mnt("/proc/self/mounts", [&](mntent *mentry) {
if (TMPFS_MNT(system) || TMPFS_MNT(vendor) || TMPFS_MNT(sbin) || TMPFS_MNT(product))
if (TMPFS_MNT(system) || TMPFS_MNT(vendor) || TMPFS_MNT(product) || TMPFS_MNT(system_ext))
targets.emplace_back(mentry->mnt_dir);
return true;
});
for (auto &s : targets)
for (auto &s : reversed(targets))
lazy_unmount(s.data());
targets.clear();
@ -104,7 +105,7 @@ void hide_unmount(int pid) {
return true;
});
for (auto &s : targets)
for (auto &s : reversed(targets))
lazy_unmount(s.data());
}

View File

@ -121,15 +121,13 @@ static int rm_list(const char *pkg, const char *proc = "") {
// Critical region
mutex_guard lock(monitor_lock);
bool remove = false;
auto next = hide_set.begin();
decltype(next) cur;
while (next != hide_set.end()) {
cur = next;
++next;
if (cur->first == pkg && (proc[0] == '\0' || cur->second == proc)) {
for (auto it = hide_set.begin(); it != hide_set.end();) {
if (it->first == pkg && (proc[0] == '\0' || it->second == proc)) {
remove = true;
LOGI("hide_list rm: [%s]\n", cur->second.data());
hide_set.erase(cur);
LOGI("hide_list rm: [%s]\n", it->second.data());
it = hide_set.erase(it);
} else {
++it;
}
}
if (!remove)
@ -166,6 +164,11 @@ static void init_list(const char *pkg, const char *proc) {
#define LEGACY_LIST MODULEROOT "/.core/hidelist"
#define SAFETYNET_COMPONENT "com.google.android.gms/.droidguard.DroidGuardService"
#define SAFETYNET_PROCESS "com.google.android.gms.unstable"
#define SAFETYNET_PKG "com.google.android.gms"
#define MICROG_SAFETYNET "org.microg.gms.droidguard"
bool init_list() {
LOGD("hide_list: initialize\n");
@ -196,6 +199,11 @@ bool init_list() {
init_list(SAFETYNET_PKG, SAFETYNET_PROCESS);
init_list(MICROG_SAFETYNET, SAFETYNET_PROCESS);
// We also need to hide the default GMS process if MAGISKTMP != /sbin
// The snet process communicates with the main process and get additional info
if (MAGISKTMP != "/sbin")
init_list(SAFETYNET_PKG, SAFETYNET_PKG);
update_uid_map();
return true;
}

View File

@ -15,11 +15,6 @@
#define SIGTERMTHRD SIGUSR1
#define SIGZYGOTE SIGUSR2
#define SAFETYNET_COMPONENT "com.google.android.gms/.droidguard.DroidGuardService"
#define SAFETYNET_PROCESS "com.google.android.gms.unstable"
#define SAFETYNET_PKG "com.google.android.gms"
#define MICROG_SAFETYNET "org.microg.gms.droidguard"
// CLI entries
void launch_magiskhide(int client);
int stop_magiskhide();