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?
I went through the su.c file in path system/extras/su but I'm unable to understand the whole code.
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?
ChainFire has written a a guide on su and how to use it for normal apps. If you're intending on working with anything other than your own phone I suggest this is the approach you follow.
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 modifysystem/core/include/private/android_filesystem_config.h
file (structureandroid_files[]
), for instance for su program you can see how this bit is set: