5

I have an Android TV box (4.4.2, armv7), and I can login the device as root by ADB (local network). What I want to do is to give certain apps root permission. How can I do it?

0

1 Answer 1

5

You don't give certain apps root permission, but certain apps ask for root permission by executing su binary. It's the developer of the app who decides if the app would perform some tasks with root privileges or not. In order to let apps request root privileges, you need to root your device using e.g. Magisk, SuperSU etc. (whatever works on your device).

When you get root privileges on adb (e.g. by executing adb root or adb shell su) it runs adbd process on device as root (UID 0) user. So all commands which you run through adb have root privileges. To grant root access to apps you need a special su binary which is not shipped with Android.

The usual su binary (like on any UNIX-like OS) makes a transition to UID 0 by making setuid syscall to kernel. This is not possible on Android due to certain restrictions. The special su binary (the one provided by rooting solutions like Magisk) connects to a background daemon to get a root shell for the requesting app, where the app can execute commands with root privileges. However the app itself is still running with its own UID (assigned at the time of installation).

For more details see:

5
  • Thanks for ans, and I found there is a file named su which's location is /system/xbin and I run chmod 777 to this file. Then I install supersu on the box but it remind "su binary occupied". So do I have a solution to solve it?
    – punnpkin
    May 24, 2020 at 9:30
  • 1
    @punnpkin you need to root your device, using e.g. Magisk or SuperSU. The su binary already provided in Android cannot be used with SuperSU. They provide their own su binaries. That's what I tried to explain in the answer. For more details see linked answers. May 24, 2020 at 9:36
  • OK, I learned it, Actually, I'm just looking for a way to root my device without changing the rom. (Because it has some customized content.)
    – punnpkin
    May 24, 2020 at 9:52
  • 2
    I don't understand this answer. If you can adb root and you run have root privs, why can't you run the app? That doesn't make sense, you grant root access to anything root runs. Why can't someone with root access run an android app? Jul 18, 2022 at 4:04
  • 1
    @EvanCarroll because Android apps cannot make use of SUID bit. Please read “How Android restricts root access?” in the linked answers. Jul 18, 2022 at 5:28

Not the answer you're looking for? Browse other questions tagged .