Add KSU_CMDLINE configuration to enable the KernelSU command line option and implement the corresponding status read function
Co-authored-by: rsuntk <rsuntk@yukiprjkt.my.id> Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com> Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
This commit is contained in:
@@ -46,6 +46,14 @@ config KSU_ALLOWLIST_WORKAROUND
|
|||||||
Enable session keyring init workaround for problematic devices.
|
Enable session keyring init workaround for problematic devices.
|
||||||
Useful for situations where the SU allowlist is not kept after a reboot
|
Useful for situations where the SU allowlist is not kept after a reboot
|
||||||
|
|
||||||
|
config KSU_CMDLINE
|
||||||
|
bool "Enable KernelSU cmdline"
|
||||||
|
depends on KSU && KSU != m
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
Enable a cmdline called kernelsu.enabled
|
||||||
|
Value 1 means enabled, value 0 means disabled.
|
||||||
|
|
||||||
config KPM
|
config KPM
|
||||||
bool "Enable SukiSU KPM"
|
bool "Enable SukiSU KPM"
|
||||||
depends on KSU
|
depends on KSU
|
||||||
|
|||||||
33
kernel/ksu.c
33
kernel/ksu.c
@@ -15,6 +15,24 @@
|
|||||||
#include <linux/susfs.h>
|
#include <linux/susfs.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_KSU_CMDLINE
|
||||||
|
#include <linux/init.h>
|
||||||
|
|
||||||
|
// use get_ksu_state()!
|
||||||
|
unsigned int enable_kernelsu = 1; // enabled by default
|
||||||
|
static int __init read_kernelsu_state(char *s)
|
||||||
|
{
|
||||||
|
if (s)
|
||||||
|
enable_kernelsu = simple_strtoul(s, NULL, 0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
__setup("kernelsu.enabled=", read_kernelsu_state);
|
||||||
|
|
||||||
|
bool get_ksu_state(void) { return enable_kernelsu >= 1; }
|
||||||
|
#else
|
||||||
|
bool get_ksu_state(void) { return true; }
|
||||||
|
#endif /* CONFIG_KSU_CMDLINE */
|
||||||
|
|
||||||
static struct workqueue_struct *ksu_workqueue;
|
static struct workqueue_struct *ksu_workqueue;
|
||||||
|
|
||||||
bool ksu_queue_work(struct work_struct *work)
|
bool ksu_queue_work(struct work_struct *work)
|
||||||
@@ -43,6 +61,15 @@ extern void ksu_ksud_exit();
|
|||||||
|
|
||||||
int __init ksu_kernelsu_init(void)
|
int __init ksu_kernelsu_init(void)
|
||||||
{
|
{
|
||||||
|
pr_info("kernelsu.enabled=%d\n",
|
||||||
|
get_ksu_state());
|
||||||
|
|
||||||
|
#ifdef CONFIG_KSU_CMDLINE
|
||||||
|
if (!get_ksu_state()) {
|
||||||
|
pr_info_once("drivers is disabled.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef CONFIG_KSU_DEBUG
|
#ifdef CONFIG_KSU_DEBUG
|
||||||
pr_alert("*************************************************************");
|
pr_alert("*************************************************************");
|
||||||
pr_alert("** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **");
|
pr_alert("** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **");
|
||||||
@@ -83,6 +110,11 @@ int __init ksu_kernelsu_init(void)
|
|||||||
|
|
||||||
void ksu_kernelsu_exit(void)
|
void ksu_kernelsu_exit(void)
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_KSU_CMDLINE
|
||||||
|
if (!get_ksu_state()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
ksu_allowlist_exit();
|
ksu_allowlist_exit();
|
||||||
|
|
||||||
ksu_throne_tracker_exit();
|
ksu_throne_tracker_exit();
|
||||||
@@ -104,6 +136,7 @@ MODULE_LICENSE("GPL");
|
|||||||
MODULE_AUTHOR("weishu");
|
MODULE_AUTHOR("weishu");
|
||||||
MODULE_DESCRIPTION("Android KernelSU");
|
MODULE_DESCRIPTION("Android KernelSU");
|
||||||
|
|
||||||
|
#include <linux/version.h>
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
|
||||||
MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
|
MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user