如何修改 AOSP 以允许特定应用获得 root 访问权限? [英] How to modify AOSP to allow specific apps to get root access?

查看:93
本文介绍了如何修改 AOSP 以允许特定应用获得 root 访问权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究 AOSP.我已经成功地添加了我的 apk 来构建.现在我想授予对我的应用程序的 root 访问权限.我不想为其他应用程序提供 root 访问权限,也不想在我的构建中安装超级用户应用程序.我只想添加我的应用程序以获得 root 访问权限.我怎样才能做到这一点?

I'm working on AOSP. I've successfully added my apk to build. Now I want to give root access to my app. I don't want to provide root access to other apps or to install the Superuser app in my build. I just want to add my app to get root access. How can I achieve that?

我浏览了路径 system/extras/su 中的 su.c 文件,但我无法理解整个代码.

I went through the su.c file in path system/extras/su but I'm unable to understand the whole code.

当我浏览代码时,我认为如果我可以修改 su.c 为我的应用程序提供 root 访问权限,我的目标就可以实现,编译它并将二进制添加到构建中.我说得对吗?

When I went through the code, I think my objective can be achieved if I could modify su.c to provide root access to my app,compile it and add the binary to the build. Am I right?

推荐答案

您正朝着正确的方向前进.您需要检查 su.c 的源代码 您可能面临的唯一问题是如何以 root 身份运行您的程序.为此,您需要为应用程序的可执行文件设置 SUID 粘滞位.为此,您需要修改 system/core/include/private/android_filesystem_config.h 文件(结构 android_files[]),例如对于 su 程序,您可以看到这是如何实现的位已设置:

You're moving in the right direction. You need to check the sources for su.c The only problem that you can face is how to run your program as root. To do this you need to set SUID sticky bit for the executable of your application. To do this you need to modify system/core/include/private/android_filesystem_config.h file (structure android_files[]), for instance for su program you can see how this bit is set:

{ 06755, AID_ROOT,      AID_ROOT,      "system/xbin/su" },

这篇关于如何修改 AOSP 以允许特定应用获得 root 访问权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆