You've already forked ReZygisk
mirror of
https://github.com/PerformanC/ReZygisk.git
synced 2025-09-06 06:37:01 +00:00
remove: Rooted mns state for simplification
This commit removes the "Rooted" mount namespace state, as it wouldn't fit in the categories made by root implementations. The three major root implementations divide apps into three categories: SU, Umounted, (with) Mounts. The SU one consists of apps that are allowed to elevate privileges, those don't have their mounts modified, and keep root mounts. As for Umounted, it consists of apps that will have root-related mounts umounted before being executed. And finally (with) mounts which are apps that although are not allowed to elevate privileges, still have the root-related mounts kept. Knowing that we can merge both SU and (with) Mounts into the same category: No modification to mounts/Keep root-related mounts. With that, "Mounts" mns state is also unmodified, compared to old "Modules" mns state. Those changes also reflect on the issue where new apps couldn't ask Magisk for root as they would have SU mount umounted, which now, as ReZygisk leave them unmodified, they can.
This commit is contained in:
@@ -50,8 +50,7 @@ struct rezygisk_info {
|
||||
|
||||
enum mount_namespace_state {
|
||||
Clean,
|
||||
Rooted,
|
||||
Module
|
||||
Mounted
|
||||
};
|
||||
|
||||
#define TMP_PATH "/data/adb/rezygisk"
|
||||
|
||||
@@ -158,8 +158,7 @@ bool update_mnt_ns(enum mount_namespace_state mns_state, bool dry_run) {
|
||||
|
||||
const char *mns_state_str = NULL;
|
||||
if (mns_state == Clean) mns_state_str = "clean";
|
||||
else if (mns_state == Module) mns_state_str = "module";
|
||||
else if (mns_state == Rooted) mns_state_str = "rooted";
|
||||
else if (mns_state == Mounted) mns_state_str = "mounted";
|
||||
else mns_state_str = "unknown";
|
||||
|
||||
LOGD("set mount namespace to [%s] fd=[%d]: %s", ns_path, updated_ns, mns_state_str);
|
||||
@@ -183,17 +182,23 @@ DCL_HOOK_FUNC(int, unshare, int flags) {
|
||||
// This is reproducible on the official AVD running API 26 and 27.
|
||||
// Simply avoid doing any unmounts for SysUI to avoid potential issues.
|
||||
!g_ctx->flags[SERVER_FORK_AND_SPECIALIZE] && !(g_ctx->info_flags & PROCESS_IS_FIRST_STARTED)) {
|
||||
if (g_ctx->info_flags & (PROCESS_IS_MANAGER | PROCESS_GRANTED_ROOT)) {
|
||||
update_mnt_ns(Rooted, false);
|
||||
} else if (!(g_ctx->flags[DO_REVERT_UNMOUNT])) {
|
||||
update_mnt_ns(Module, false);
|
||||
}
|
||||
|
||||
/* INFO: There might be cases, specifically in Magisk, where the app is in
|
||||
DenyList but also has root privileges. For those, it is up to the
|
||||
user remove it, and the weird behavior is expected, as the weird
|
||||
user behavior. */
|
||||
|
||||
/* INFO: For cases like Magisk, where you can only give an app SU if it was
|
||||
either requested before or if it's not in DenyList, we cannot
|
||||
umount it, or else it will not be (easily) possible to give new
|
||||
apps SU. Apps that are not marked in APatch/KernelSU to be umounted
|
||||
are also expected to have AP/KSU mounts there, so we will follow the
|
||||
same idea by not umounting any mount. */
|
||||
|
||||
if (g_ctx->info_flags & (PROCESS_IS_MANAGER | PROCESS_GRANTED_ROOT) || !(g_ctx->flags[DO_REVERT_UNMOUNT])) {
|
||||
update_mnt_ns(Mounted, false);
|
||||
}
|
||||
|
||||
old_unshare(CLONE_NEWNS);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user