瑞芯微Rockchip开发者社区
直播中

王斌

7年用户 1320经验值
私信 关注
[问答]

请问RK356X And​​roid11.0如何获取ROOT权限?

RK356X和android11.0如何获取ROOT权限?

回帖(1)

翁靠庭

2022-3-2 15:21:01

  • 测试平台:RK356X Android11.0
  • 修改步骤




  • 需要编译userdebug版本
  • 关闭selinux
    $ vim device/rockchip/common/BoardConfig.mk

    @@ -59,7 +59,7 @@ BOARD_BOOT_HEADER_VERSION ?= 2
            BOARD_MKBOOTIMG_ARGS :=
            BOARD_PREBUILT_DTBOIMAGE ?= $(TARGET_DEVICE_DIR)/dtbo.img
            BOARD_ROCKCHIP_VIRTUAL_AB_LINUX_ENABLE ?=
            ING false = 真
            +BOARD_SELINUX_ENFORCING ?= 假
  • 修改su.cpp,注释用户组权限检测
    $ vim system/extras/su/su.cpp

    @@ -80,8 +80,8 @@ void extract_uidgids(const char* uidgids, uid_t* uid, gid_t* gid, gid_t* gids, i }
            int main(int argc, char** argv) {
            - uid_t current_uid = getuid();
            - if (current_uid != AID_ROOT && current_uid != AID_SHELL) error(1, 0, "notallowed");
            + //uid_t current_uid = getuid();
            + //if (current_uid != AID_ROOT && current_uid != AID_SHELL) error(1, 0, "notallowed");
            // Handle -h and --help.
            ++argv;
  • 给 su 文件默认授予 root 权限
    $ vim system/core/libcutils/fs_config.cpp

    @@ -188,7 +188,7 @@ static const struct fs_path_config android_files[] = {
    // the following two files are INTENTIONALLY set-uid, but they
    // are NOT included on user builds.
    { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/procmem" },
    - { 04750, AID_ROOT, AID_SHELL, 0, "system/xbin/su" },
    + { 06755, AID_ROOT, AID_SHELL, 0, "system/xbin/su" },
    // the following files have enhanced capabilities and ARE included
    // in user builds.
    $ vim frameworks/base/core/jni/com_android_internal_os_Zygote.cpp

    @@ -656,6 +656,7 @@ static void EnableKeepCapabilities(fail_fn_t fail_fn) {
    }
    static void DropCapabilitiesBoundingSet(fail_fn_t fail_fn) {
    +/*
            for (int i = 0; prctl(PR_CAPBSET_READ, i, 0, 0, 0) >= 0; i++) {;
                    if (prctl(PR_CAPBSET_DROP, i, 0, 0, 0) == -1) {
                            if (errno == EINVAL) {

    @@ -666,6 +667,7 @@ static void DropCapabilitiesBoundingSet(fail_fn_t fail_fn) {
                            }
                    }
            }
    + */
    }
    $ vim kernel/security/commoncap.c

    @@ -1147,12 +1147,12 @@ int cap_task_setnice(struct task_struct *p, int nice)
    static int cap_prctl_drop(unsigned long cap)
    {
            struct cred *new;
    +/*
            if (!ns_capable(current_user_ns(), CAP_SETPCAP))
            返回-EPERM;
            如果(!cap_valid(cap))
            返回-EINVAL;
    +*/
            new = prepare_creds();
举报

更多回帖

发帖
×
20
完善资料,
赚取积分