kernel: added new prctl CMD_GET_MANAGER_UID to get the uid of the crowned manager

manager: show crowned manager uid in infocard when developer options is enabled
This commit is contained in:
Rifat Azad
2025-06-30 14:19:07 +06:00
parent 98b9863041
commit 4e3f06d405
7 changed files with 48 additions and 1 deletions
+7
View File
@@ -25,6 +25,13 @@ Java_com_rifsxd_ksunext_Natives_getVersion(JNIEnv *env, jobject) {
return get_version();
}
extern "C"
JNIEXPORT jint JNICALL
Java_com_rifsxd_ksunext_Natives_getManagerUid(JNIEnv *env, jobject) {
uid_t manager_uid = get_manager_uid();
return (jint)manager_uid;
}
extern "C"
JNIEXPORT jstring JNICALL
Java_com_rifsxd_ksunext_Natives_getHookMode(JNIEnv *env, jobject) {
+8
View File
@@ -30,6 +30,7 @@
#define CMD_IS_SU_ENABLED 14
#define CMD_ENABLE_SU 15
#define CMD_HOOK_MODE 16
#define CMD_GET_MANAGER_UID 17
static bool ksuctl(int cmd, void* arg1, void* arg2) {
int32_t result = 0;
@@ -63,12 +64,19 @@ int get_version(void) {
return version;
}
uid_t get_manager_uid() {
uid_t manager_uid = (uid_t)-1;
ksuctl(CMD_GET_MANAGER_UID, &manager_uid, nullptr);
return manager_uid;
}
const char* get_hook_mode() {
static char mode[16];
ksuctl(CMD_HOOK_MODE, mode, nullptr);
return mode;
}
bool get_allow_list(int *uids, int *size) {
return ksuctl(CMD_GET_SU_LIST, uids, size);
}
+2
View File
@@ -11,6 +11,8 @@ bool become_manager(const char *);
int get_version();
uid_t get_manager_uid();
const char* get_hook_mode();
bool get_allow_list(int *uids, int *size);