1

On standard GNU/Linux computers, SELinux comes with a set of tools allowing the administrator to troubleshoot permission issues.

Such tools allow to:

  • Temporarily switch a single domain in permissive mode, thus reducing the security impact on the whole device compared to a global permissive mode (and yes, per-domain permissive mode is supported in Android's SELinux): semanage
  • List existing SELinux users, roles and categories (AFAIK categories are used for multi-users devices): semanage, seinfo, chcat
  • Query the SELinux policy: sesearch

I did not find any of these tools in my device.

Is there any equivalent or a way to install them?

4
  • Do not compare Android with GNU/Linux: the former is only inspired by the latter, and runs a Linux modified kernel, but Android is not Linux.
    – Grimoire
    Commented Jul 27, 2016 at 9:45
  • 1
    @DeathMaskSalesman: I know this, but SELinux remains SELinux, and the tools mentioned are all part of the SELinux core tools and not part of the GNU utils. There is no reason why SELinux core tools would not be available where SELinux is enabled, unless one wants to remove to end-users the control of their own platform (at least it is the only reason I can think of yet: we are meant to be consumers, not administrators). Commented Jul 27, 2016 at 12:00
  • Kudos for the last bit! As far as I know, there are only three commands connected to SELinux that are available on Android: selinuxenabled, sestatus and setenforce. You may also have chcon and runcon.
    – Grimoire
    Commented Jul 27, 2016 at 12:08
  • @DeathMaskSalesman: A complete list of commands provided by the original SELinux for Android and available by default is available on SELinux website. I don't think there is any plan to add more and if no intermediary took care of adding them, porting these commands will therefore be up to the users community. The point is I don't know if there is already such project. Commented Jul 27, 2016 at 12:19

1 Answer 1

0

As I feared, Google is against letting people tweak SELinux. This is stated explicitely in the Android Compatibility Definition Document:

SELinux or any other security features implemented below the Android framework:

  • [...]

  • SHOULD NOT be user or developer configurable.

However, the good news is that there is indeed a FOSS project porting SELinux tools to Android: setools-android. This tools ports the usual seinfo and sesearch commands as can be found in the upstream SELinux Tools project, but it also adds the sepolicy-inject command which allows to modify the current policy or set a domain in permissive mode.

This however suffer from a big issue: unlike on standard computers, modifications made to the /sepolicy file which stores SELinux policy are not persistent and will be lost upon device restart.

In fact, this file as part of the root directory is stored in a RAM disk image which, in turn, is stored in the device's boot image and extracted during the device's boot sequence. To apply permanent modification to this file it is therefore necessary to modify the version stored within the device's boot image.

While the operation may still be possible from the device itself (as far as I know SuperSU for instance updates the boot image as part of its installation procedure), for my use-case I find it more convenient to do the operation from an external computer connected to the phone (here is my detailed procedure). Tools running on the device still remain useful though when frequent checks and updates of the SELinux policy are required (typically during development stages) and for automation (if a project needs a SuperSU-like installer for instance).

You must log in to answer this question.

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