MonoMod / MonoMod.Common

Common code used by MonoMod and other .NET modding libraries. Not to be confused with MonoMod.Utils (for mods).
MIT License
74 stars 32 forks source link

Fix Android support by bypassing SELinux #20

Closed Mewnojs closed 2 years ago

Mewnojs commented 2 years ago

Use /data directory and /system/build.prop to identify android device, since /proc/sys/kernel/ostype is inaccessible on later version of Android (>=5.0) because of SELinux policies.

0x0ade commented 2 years ago

Does the directory /etc/selinux exist on your device? I can only check with Termux right now, and something is linking /etc to /system/etc, dunno if it's Android or Termux.

If it does, I'd like to change the check so that:

This should also fix possible issues in other Linux environments with SELinux enforced.

Mewnojs commented 2 years ago

Does the directory /etc/selinux exist on your device? I can only check with Termux right now, and something is linking /etc to /system/etc, dunno if it's Android or Termux.

If it does, I'd like to change the check so that:

* `/etc/selinux` implies Linux,

* `/etc/selinux` + the two Android-specific paths imply Android,

* anything else falls through to `/proc/sys/kernel/ostype` and then the macOS `SystemVersion` check.

This should also fix possible issues in other Linux environments with SELinux enforced.

Yes it does, and the symbol link /etc -> /system/etc is documented in here, giving us a steady proof of doing that.

0x0ade commented 2 years ago

I've just merged your changes with a subsequent cleanup commit. Thank you :)