manager: fix legacy get version
Co-authored-by: weishu <twsxtd@gmail.com> Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
This commit is contained in:
@@ -13,7 +13,7 @@ NativeBridgeNP(getVersion, jint) {
|
|||||||
return (jint)version;
|
return (jint)version;
|
||||||
}
|
}
|
||||||
// try legacy method as fallback
|
// try legacy method as fallback
|
||||||
return legacy_get_version();
|
return legacy_get_info().version;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get VERSION FULL
|
// get VERSION FULL
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// Created by weishu on 2022/12/9.
|
// Created by weishu on 2022/12/9.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <sys/prctl.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -12,8 +11,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include <sys/syscall.h>
|
|
||||||
|
|
||||||
#include "prelude.h"
|
#include "prelude.h"
|
||||||
#include "ksu.h"
|
#include "ksu.h"
|
||||||
|
|
||||||
@@ -27,34 +24,6 @@ extern const char* zako_file_verrcidx2str(uint8_t index);
|
|||||||
|
|
||||||
#endif // __aarch64__ || _M_ARM64 || __arm__ || _M_ARM
|
#endif // __aarch64__ || _M_ARM64 || __arm__ || _M_ARM
|
||||||
|
|
||||||
#define KERNEL_SU_OPTION 0xDEADBEEF
|
|
||||||
|
|
||||||
#define CMD_GRANT_ROOT 0
|
|
||||||
|
|
||||||
#define CMD_BECOME_MANAGER 1
|
|
||||||
#define CMD_GET_VERSION 2
|
|
||||||
#define CMD_ALLOW_SU 3
|
|
||||||
#define CMD_DENY_SU 4
|
|
||||||
#define CMD_GET_SU_LIST 5
|
|
||||||
#define CMD_GET_DENY_LIST 6
|
|
||||||
#define CMD_CHECK_SAFEMODE 9
|
|
||||||
|
|
||||||
#define CMD_GET_APP_PROFILE 10
|
|
||||||
#define CMD_SET_APP_PROFILE 11
|
|
||||||
|
|
||||||
#define CMD_IS_UID_GRANTED_ROOT 12
|
|
||||||
#define CMD_IS_UID_SHOULD_UMOUNT 13
|
|
||||||
#define CMD_IS_SU_ENABLED 14
|
|
||||||
#define CMD_ENABLE_SU 15
|
|
||||||
|
|
||||||
#define CMD_GET_VERSION_FULL 0xC0FFEE1A
|
|
||||||
|
|
||||||
#define CMD_ENABLE_KPM 100
|
|
||||||
#define CMD_HOOK_TYPE 101
|
|
||||||
#define CMD_DYNAMIC_MANAGER 103
|
|
||||||
#define CMD_GET_MANAGERS 104
|
|
||||||
#define CMD_ENABLE_UID_SCANNER 105
|
|
||||||
|
|
||||||
static int fd = -1;
|
static int fd = -1;
|
||||||
|
|
||||||
static inline int scan_driver_fd() {
|
static inline int scan_driver_fd() {
|
||||||
@@ -107,12 +76,6 @@ static int ksuctl(unsigned long op, void* arg) {
|
|||||||
return ioctl(fd, op, arg);
|
return ioctl(fd, op, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ksuctl_prctl(int cmd, void* arg1, void* arg2) {
|
|
||||||
int32_t result = 0;
|
|
||||||
int32_t rtn = prctl(KERNEL_SU_OPTION, cmd, arg1, arg2, &result);
|
|
||||||
return result == KERNEL_SU_OPTION && rtn == -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct ksu_get_info_cmd g_version = {0};
|
static struct ksu_get_info_cmd g_version = {0};
|
||||||
|
|
||||||
struct ksu_get_info_cmd get_info() {
|
struct ksu_get_info_cmd get_info() {
|
||||||
@@ -127,6 +90,14 @@ uint32_t get_version() {
|
|||||||
return info.version;
|
return info.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ksu_version_info legacy_get_info()
|
||||||
|
{
|
||||||
|
int32_t version = -1;
|
||||||
|
int32_t flags = 0;
|
||||||
|
ksuctl_prctl(CMD_GET_VERSION, &version, &flags);
|
||||||
|
return (struct ksu_version_info){version, flags};
|
||||||
|
}
|
||||||
|
|
||||||
bool get_allow_list(struct ksu_get_allow_list_cmd *cmd) {
|
bool get_allow_list(struct ksu_get_allow_list_cmd *cmd) {
|
||||||
return ksuctl(KSU_IOCTL_GET_ALLOW_LIST, cmd) == 0;
|
return ksuctl(KSU_IOCTL_GET_ALLOW_LIST, cmd) == 0;
|
||||||
}
|
}
|
||||||
@@ -139,12 +110,18 @@ bool is_safe_mode() {
|
|||||||
|
|
||||||
bool is_lkm_mode() {
|
bool is_lkm_mode() {
|
||||||
auto info = get_info();
|
auto info = get_info();
|
||||||
|
if (info.version > 0) {
|
||||||
return (info.flags & 0x1) != 0;
|
return (info.flags & 0x1) != 0;
|
||||||
|
}
|
||||||
|
return (legacy_get_info().flags & 0x1) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_manager() {
|
bool is_manager() {
|
||||||
auto info = get_info();
|
auto info = get_info();
|
||||||
|
if (info.version > 0) {
|
||||||
return (info.flags & 0x2) != 0;
|
return (info.flags & 0x2) != 0;
|
||||||
|
}
|
||||||
|
return legacy_get_info().version;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool uid_should_umount(int uid) {
|
bool uid_should_umount(int uid) {
|
||||||
@@ -220,13 +197,6 @@ bool is_kernel_umount_enabled() {
|
|||||||
return value != 0;
|
return value != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int legacy_get_version() {
|
|
||||||
int32_t version = -1;
|
|
||||||
int32_t flags = 0;
|
|
||||||
ksuctl_prctl(CMD_GET_VERSION, &version, &flags);
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_full_version(char* buff) {
|
void get_full_version(char* buff) {
|
||||||
struct ksu_get_full_version_cmd cmd = {0};
|
struct ksu_get_full_version_cmd cmd = {0};
|
||||||
if (ksuctl(KSU_IOCTL_GET_FULL_VERSION, &cmd) == 0) {
|
if (ksuctl(KSU_IOCTL_GET_FULL_VERSION, &cmd) == 0) {
|
||||||
|
|||||||
@@ -9,13 +9,47 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
|
||||||
|
#define KERNEL_SU_OPTION 0xDEADBEEF
|
||||||
|
|
||||||
|
#define CMD_GRANT_ROOT 0
|
||||||
|
|
||||||
|
#define CMD_BECOME_MANAGER 1
|
||||||
|
#define CMD_GET_VERSION 2
|
||||||
|
#define CMD_ALLOW_SU 3
|
||||||
|
#define CMD_DENY_SU 4
|
||||||
|
#define CMD_GET_SU_LIST 5
|
||||||
|
#define CMD_GET_DENY_LIST 6
|
||||||
|
#define CMD_CHECK_SAFEMODE 9
|
||||||
|
|
||||||
|
#define CMD_GET_APP_PROFILE 10
|
||||||
|
#define CMD_SET_APP_PROFILE 11
|
||||||
|
|
||||||
|
#define CMD_IS_UID_GRANTED_ROOT 12
|
||||||
|
#define CMD_IS_UID_SHOULD_UMOUNT 13
|
||||||
|
#define CMD_IS_SU_ENABLED 14
|
||||||
|
#define CMD_ENABLE_SU 15
|
||||||
|
|
||||||
|
#define CMD_GET_VERSION_FULL 0xC0FFEE1A
|
||||||
|
|
||||||
|
#define CMD_ENABLE_KPM 100
|
||||||
|
#define CMD_HOOK_TYPE 101
|
||||||
|
#define CMD_DYNAMIC_MANAGER 103
|
||||||
|
#define CMD_GET_MANAGERS 104
|
||||||
|
#define CMD_ENABLE_UID_SCANNER 105
|
||||||
|
|
||||||
|
static inline bool ksuctl_prctl(int cmd, void* arg1, void* arg2) {
|
||||||
|
int32_t result = 0;
|
||||||
|
int32_t rtn = prctl(KERNEL_SU_OPTION, cmd, arg1, arg2, &result);
|
||||||
|
return result == KERNEL_SU_OPTION && rtn == -1;
|
||||||
|
}
|
||||||
|
|
||||||
#define KSU_FULL_VERSION_STRING 255
|
#define KSU_FULL_VERSION_STRING 255
|
||||||
|
|
||||||
uint32_t get_version();
|
uint32_t get_version();
|
||||||
|
|
||||||
int legacy_get_version(void);
|
|
||||||
|
|
||||||
bool uid_should_umount(int uid);
|
bool uid_should_umount(int uid);
|
||||||
|
|
||||||
bool is_safe_mode();
|
bool is_safe_mode();
|
||||||
@@ -260,6 +294,13 @@ struct ksu_enable_uid_scanner_cmd {
|
|||||||
#define KSU_IOCTL_GET_MANAGERS _IOC(_IOC_READ|_IOC_WRITE, 'K', 104, 0)
|
#define KSU_IOCTL_GET_MANAGERS _IOC(_IOC_READ|_IOC_WRITE, 'K', 104, 0)
|
||||||
#define KSU_IOCTL_ENABLE_UID_SCANNER _IOC(_IOC_READ|_IOC_WRITE, 'K', 105, 0)
|
#define KSU_IOCTL_ENABLE_UID_SCANNER _IOC(_IOC_READ|_IOC_WRITE, 'K', 105, 0)
|
||||||
|
|
||||||
bool get_allow_list(struct ksu_get_allow_list_cmd*);
|
bool get_allow_list(struct ksu_get_allow_list_cmd *);
|
||||||
|
|
||||||
|
struct ksu_version_info legacy_get_info();
|
||||||
|
|
||||||
|
struct ksu_version_info {
|
||||||
|
int32_t version;
|
||||||
|
int32_t flags;
|
||||||
|
};
|
||||||
|
|
||||||
#endif //KERNELSU_KSU_H
|
#endif //KERNELSU_KSU_H
|
||||||
@@ -52,7 +52,6 @@ import com.sukisu.ultra.ui.theme.getCardElevation
|
|||||||
import com.sukisu.ultra.ui.util.*
|
import com.sukisu.ultra.ui.util.*
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
|||||||
Reference in New Issue
Block a user