kernel: allow to change manager in debug mode (#111)
This commit is contained in:
17
kernel/ksu.c
17
kernel/ksu.c
@@ -115,11 +115,6 @@ static bool become_manager(char *pkg)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ksu_is_manager_uid_valid()) {
|
|
||||||
pr_info("manager already exist: %d\n", ksu_manager_uid);
|
|
||||||
return is_manager();
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = (char *)kmalloc(PATH_MAX, GFP_ATOMIC);
|
buf = (char *)kmalloc(PATH_MAX, GFP_ATOMIC);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
pr_err("kalloc path failed.\n");
|
pr_err("kalloc path failed.\n");
|
||||||
@@ -195,6 +190,18 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
|
|||||||
pr_info("option: 0x%x, cmd: %ld\n", option, arg2);
|
pr_info("option: 0x%x, cmd: %ld\n", option, arg2);
|
||||||
|
|
||||||
if (arg2 == CMD_BECOME_MANAGER) {
|
if (arg2 == CMD_BECOME_MANAGER) {
|
||||||
|
// quick check
|
||||||
|
if (is_manager()) {
|
||||||
|
if (copy_to_user(result, &reply_ok, sizeof(reply_ok))) {
|
||||||
|
pr_err("become_manager: prctl reply error\n");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (ksu_is_manager_uid_valid()) {
|
||||||
|
pr_info("manager already exist: %d\n", ksu_manager_uid);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// someone wants to be root manager, just check it!
|
// someone wants to be root manager, just check it!
|
||||||
// arg3 should be `/data/data/<manager_package_name>`
|
// arg3 should be `/data/data/<manager_package_name>`
|
||||||
char param[128];
|
char param[128];
|
||||||
|
|||||||
@@ -24,7 +24,11 @@ extern uid_t ksu_manager_uid;
|
|||||||
|
|
||||||
static inline bool ksu_is_manager_uid_valid()
|
static inline bool ksu_is_manager_uid_valid()
|
||||||
{
|
{
|
||||||
|
#ifndef CONFIG_KSU_DEBUG
|
||||||
return ksu_manager_uid != INVALID_UID;
|
return ksu_manager_uid != INVALID_UID;
|
||||||
|
#else
|
||||||
|
return false; // always allow in debug mode
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uid_t ksu_get_manager_uid()
|
static inline uid_t ksu_get_manager_uid()
|
||||||
|
|||||||
Reference in New Issue
Block a user