You've already forked ReZygisk
mirror of
https://github.com/PerformanC/ReZygisk.git
synced 2025-09-06 06:37:01 +00:00
add: KernelSU Next recognition support
This commit adds support for recognizing KernelSU (KSUN) manager to ReZygiskd.
This commit is contained in:
@@ -30,6 +30,7 @@ void root_impls_setup(void) {
|
|||||||
impl.impl = Multiple;
|
impl.impl = Multiple;
|
||||||
} else if (state_ksu.state == Supported) {
|
} else if (state_ksu.state == Supported) {
|
||||||
impl.impl = KernelSU;
|
impl.impl = KernelSU;
|
||||||
|
impl.variant = state_ksu.variant;
|
||||||
} else if (state_apatch.state == Supported) {
|
} else if (state_apatch.state == Supported) {
|
||||||
impl.impl = APatch;
|
impl.impl = APatch;
|
||||||
} else if (state_magisk.state == Supported) {
|
} else if (state_magisk.state == Supported) {
|
||||||
|
|||||||
@@ -19,6 +19,9 @@
|
|||||||
#define CMD_GET_VERSION 2
|
#define CMD_GET_VERSION 2
|
||||||
#define CMD_UID_GRANTED_ROOT 12
|
#define CMD_UID_GRANTED_ROOT 12
|
||||||
#define CMD_UID_SHOULD_UMOUNT 13
|
#define CMD_UID_SHOULD_UMOUNT 13
|
||||||
|
#define CMD_HOOK_MODE 16
|
||||||
|
|
||||||
|
static enum kernelsu_variants variant = KOfficial;
|
||||||
|
|
||||||
void ksu_get_existence(struct root_impl_state *state) {
|
void ksu_get_existence(struct root_impl_state *state) {
|
||||||
int version = 0;
|
int version = 0;
|
||||||
@@ -42,6 +45,15 @@ void ksu_get_existence(struct root_impl_state *state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
state->state = Supported;
|
state->state = Supported;
|
||||||
|
|
||||||
|
char mode[16] = { 0 };
|
||||||
|
prctl((signed int)KERNEL_SU_OPTION, CMD_HOOK_MODE, mode, 0, 0);
|
||||||
|
|
||||||
|
if (mode[0] != '\0') state->variant = KNext;
|
||||||
|
else state->variant = KOfficial;
|
||||||
|
|
||||||
|
state->variant = KNext;
|
||||||
|
variant = state->variant;
|
||||||
}
|
}
|
||||||
else if (version >= 1 && version <= MIN_KSU_VERSION - 1) state->state = TooOld;
|
else if (version >= 1 && version <= MIN_KSU_VERSION - 1) state->state = TooOld;
|
||||||
else state->state = Abnormal;
|
else state->state = Abnormal;
|
||||||
@@ -68,8 +80,12 @@ bool ksu_uid_should_umount(uid_t uid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ksu_uid_is_manager(uid_t uid) {
|
bool ksu_uid_is_manager(uid_t uid) {
|
||||||
|
const char *manager_path = NULL;
|
||||||
|
if (variant == KOfficial) manager_path = "/data/user_de/0/me.weishu.kernelsu";
|
||||||
|
else if (variant == KNext) manager_path = "/data/user_de/0/com.rifsxd.ksunext";
|
||||||
|
|
||||||
struct stat s;
|
struct stat s;
|
||||||
if (stat("/data/user_de/0/me.weishu.kernelsu", &s) == -1) {
|
if (stat(manager_path, &s) == -1) {
|
||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
LOGE("Failed to stat KSU manager data directory: %s\n", strerror(errno));
|
LOGE("Failed to stat KSU manager data directory: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,11 @@
|
|||||||
|
|
||||||
#include "../constants.h"
|
#include "../constants.h"
|
||||||
|
|
||||||
|
enum kernelsu_variants {
|
||||||
|
KOfficial,
|
||||||
|
KNext
|
||||||
|
};
|
||||||
|
|
||||||
void ksu_get_existence(struct root_impl_state *state);
|
void ksu_get_existence(struct root_impl_state *state);
|
||||||
|
|
||||||
bool ksu_uid_granted_root(uid_t uid);
|
bool ksu_uid_granted_root(uid_t uid);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ char *magisk_managers[] = {
|
|||||||
#define DEBUG_RAMDISK_MAGISK lp_select("/debug_ramdisk/magisk32", "/debug_ramdisk/magisk64")
|
#define DEBUG_RAMDISK_MAGISK lp_select("/debug_ramdisk/magisk32", "/debug_ramdisk/magisk64")
|
||||||
#define BITLESS_DEBUG_RAMDISK_MAGISK "/debug_ramdisk/magisk"
|
#define BITLESS_DEBUG_RAMDISK_MAGISK "/debug_ramdisk/magisk"
|
||||||
|
|
||||||
enum magisk_variants variant = Official;
|
static enum magisk_variants variant = MOfficial;
|
||||||
/* INFO: Longest path */
|
/* INFO: Longest path */
|
||||||
static char path_to_magisk[sizeof(DEBUG_RAMDISK_MAGISK)] = { 0 };
|
static char path_to_magisk[sizeof(DEBUG_RAMDISK_MAGISK)] = { 0 };
|
||||||
bool is_using_sulist = false;
|
bool is_using_sulist = false;
|
||||||
@@ -74,7 +74,7 @@ void magisk_get_existence(struct root_impl_state *state) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
state->variant = (uint8_t)Official;
|
state->variant = (uint8_t)MOfficial;
|
||||||
|
|
||||||
for (unsigned long i = 0; i < sizeof(supported_variants) / sizeof(supported_variants[0]); i++) {
|
for (unsigned long i = 0; i < sizeof(supported_variants) / sizeof(supported_variants[0]); i++) {
|
||||||
if (strstr(magisk_info, supported_variants[i])) {
|
if (strstr(magisk_info, supported_variants[i])) {
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
#include "../constants.h"
|
#include "../constants.h"
|
||||||
|
|
||||||
enum magisk_variants {
|
enum magisk_variants {
|
||||||
Official,
|
MOfficial,
|
||||||
Kitsune
|
MKitsune
|
||||||
};
|
};
|
||||||
|
|
||||||
void magisk_get_existence(struct root_impl_state *state);
|
void magisk_get_existence(struct root_impl_state *state);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "root_impl/common.h"
|
#include "root_impl/common.h"
|
||||||
|
#include "root_impl/kernelsu.h"
|
||||||
#include "root_impl/magisk.h"
|
#include "root_impl/magisk.h"
|
||||||
|
|
||||||
int clean_namespace_fd = 0;
|
int clean_namespace_fd = 0;
|
||||||
@@ -436,7 +437,8 @@ void stringify_root_impl_name(struct root_impl impl, char *restrict output) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KernelSU: {
|
case KernelSU: {
|
||||||
strcpy(output, "KernelSU");
|
if (impl.variant == KOfficial) strcpy(output, "KernelSU");
|
||||||
|
else strcpy(output, "KernelSU Next");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -446,11 +448,8 @@ void stringify_root_impl_name(struct root_impl impl, char *restrict output) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Magisk: {
|
case Magisk: {
|
||||||
if (impl.variant == 0) {
|
if (impl.variant == MOfficial) strcpy(output, "Magisk Official");
|
||||||
strcpy(output, "Magisk Official");
|
else strcpy(output, "Magisk Kitsune");
|
||||||
} else {
|
|
||||||
strcpy(output, "Magisk Kitsune");
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -786,7 +785,7 @@ int save_mns_fd(int pid, enum MountNamespaceState mns_state, struct root_impl im
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (impl.impl == Magisk && impl.variant == Kitsune && mns_state == Clean) {
|
if (impl.impl == Magisk && impl.variant == MKitsune && mns_state == Clean) {
|
||||||
LOGI("[Magisk] Magisk Kitsune detected, will skip cache first.");
|
LOGI("[Magisk] Magisk Kitsune detected, will skip cache first.");
|
||||||
|
|
||||||
/* INFO: MagiskSU of Kitsune has a special behavior: It is only mounted
|
/* INFO: MagiskSU of Kitsune has a special behavior: It is only mounted
|
||||||
|
|||||||
Reference in New Issue
Block a user