I\'m writing an app that will use su
to execute some commands in the linux kernel. I was wondering how SuperUser figures out that the application is asking for root
Actually it's quite simple. Vanilla Android doesn't even have su
or superuser
. When you root the device you run a shell as root. Then you install the su
binary and superuser.apk
. After installing you set the shell back to it's normal permissions. All these root-only apps can now call su
to ask for root access.
When su
is run it calls superuser.apk
with a message asking you whether you want to elevate privileges. The su
binary and superuser.apk
are protected via Android's normal sandboxing. Note that once you give an app root privileges it's free to do whatever it wants including overwriting su with it's own version.