Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

Is there any way that I intentionally grant root permission to some app? Not automatically via SuperSU when a specific app asks for root permission, but in a way to pick an app via some tool and grant it root permissions.

For example, I add my favourite text app to the approved list and then I can open root files via that app.

share|improve this question
add comment

3 Answers

up vote 6 down vote accepted

Short answer: No

Long Answer:

On UNIX like systems permissions are managed with something called UIDs. Every process has one and it dictates what they can access. Moreover there're also groups that have permission that they members can use. When an app has permissions like Write to SD card they're put into a group that has this permission.

The root permissions are an exception since they are not declared in the apps manifest, but rather in the applications code. Root is also not a group but a seprate UID so it's not that easy for an app to use it.
Apps that have root rights need to be explicitly written to do so. The way this works is every time an app wants to do something as root, it has to request the su binary to do instead. This file than ask the app that manages these permissions whether the app is on the allowed list and if it isn't than prompt you to allow or deny it.
Than the action is carried out by root not the app. These actions are not an integral part of the app nut rather external executable. If you ever did a ping on your computer than you've seen a small program like this.

While hypothetically it is possible to add this to an app this would be a non-trivial process requiring knowledge of writing smali code, which is the internal format of the Dalvik Virtual Machine (this is the part of system that runs the apk file) called smali. So in reality this isn't really feasible.

You should request this feature from the developer of the app.

share|improve this answer
    
For those who don't know what smali is: It's the assembly dialect for Android's dalvik virtual machine code and used often in reverse engineering dex files. What might be a little unclear: The app has to itself take care of becoming root programmatically. That's why the developer has to include it. Adding it to SuperSU doesn't help as long as the app does not exercise its root rights. –  ce4 Jul 18 '12 at 7:48
    
So I cannot open some root text file via my favourite text editor if the programmers did not code the app to accept opening of root files? –  AnDroDroo Jul 18 '12 at 8:12
    
Absolutely correct. To give an example: if the app will not be started with root, and tries to open some "root file", it would simply get a "permission denied" -- as accessing the file will still be done with the apps UID (it will not ask for superuser permissions to open it). On the other hand, if the app is started using the root UID (i.e. su <app>), it will access that root file as root, and thus get permission. –  Izzy Jul 18 '12 at 9:18
    
That's why I was unable to use some other text editors to read root files :). –  AnDroDroo Jul 18 '12 at 12:11
    
@Izzy AFAIK you can not execute an regular Android app with root UID, or change the UID of an running app. The only thing you can do is execute command line programs with su and therefore execute commands with admin permissions. –  Robert Jul 18 '12 at 13:10
show 4 more comments

Well there is a way out, though its bit lengthy. First of all you need to have the source code of the app you need to install. Then locate the main java file(which you can find in the "package"). Just add the following code Process p = Runtime.getRuntime().exec("su");

And you are done :)

share|improve this answer
3  
That'd make the app start a root shell, but it still won't be used for anything. The app would still be accessing files through the normal Android API, not by feeding commands to that root shell. –  Wyzard Mar 2 '13 at 2:21
add comment

I have found a way that may help you. I used this to grant root access to Tasker.

If you use the terminal emulator to grant read but not write access to a folder using

  • su
  • chmod 775 /location/of/folder/

then your text editor will be able to read that directory and so if you can then try to save a file in the folder then it will try to request root permission.

It may also just give a write error.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.