MTK Android user版本如何開啟root許可權
阿新 • • 發佈:2019-01-08
(4). 如何內建Google default su
4.1 放開Google default su 只准shell/root 使用者使用的限制.
system/extras/su/su.c 中刪除下面3行程式碼
if (myuid != AID_ROOT && myuid != AID_SHELL) {
fprintf(stderr,"su: uid %d not allowed to su\n", myuid);
return 1;
}
4.2 首先將此編譯出的su 內建到system/bin, 然後修改su 的內建許可權,啟用sbit 位.
按照FAQ: FAQ09021 如何修改系統內建檔案的許可權, 使用者,屬性
更新alps/system/core/inlcude/private/android_filesystem_config.h
在android_files 陣列中
增加
{ 06755, AID_ROOT, AID_ROOT, 0, "system/bin/su" },
注意這行要放在
{ 00755, AID_ROOT, AID_SHELL, 0, "system/bin/*" },
之前
4.3 如果是KK 以及以後版本, 需要強行解除zygote 和 adbd 對Root Capabilities BoundSet 的限制
更新kernel/security/commoncap.c 中 cap_prctl_drop 函式為:
static long cap_prctl_drop(struct cred *new, unsigned long cap)
{
//mtk71029 add begin: Let 'zygote' and 'adbd' drop Root Capabilities BoundSet ineffectively
if (!strncmp(current->comm, "zygote", 16)) {
return -EINVAL;
}
if (!strncmp(current->comm, "adbd", 16)) {
return -EINVAL;
}
// add end
if (!capable(CAP_SETPCAP))
return -EPERM;
if (!cap_valid(cap))
return -EINVAL;
cap_lower(new->cap_bset, cap);
return 0;
}
重新編譯系統, 重新download 後, adb shell 進入後再輸入su 看看是否命令列由$切換到#, 如果切換即成功。